I want to display a facebox link when I click on a element when a particular condition is satisfied. I do not want the user to click if the condition is not satisfied. I am doing something like this to achieve it which is pretty ugly
<% if x == 5 %>
<a id="something" href="http://www.some_weird_link.com" rel="facebox">
<% end %>
<div>
<!-- Loads of HTML and erb code here which should be shown no matter what condition -->
</div>
<% if x == 5 %>
</a>
<% end %>
Note that I have to put an if condition just so that the </a>
does not come in my HTML when the condition is not satisfied. This looks bad.
Can you suggest me a better way of doing this ?
link_to_if
is promising but then it wants me to put the link display text in the parameter which happens to be a big <div>
in my case.