Hi all,
I am looking to implement a tabbed interface. The tabs are mere
link_to links in the template. All i need to do is, check if a
particular tab has been selected and if it has been selected, set
the :id attribute to 'current'. The css code will take care of the
rest. I know the css works because when i explicitly set the :id =>
'current without any conditions, it shows in the browser.
I have however tried many variations and all are throwing me syntax
errors. Hope someone can give me the right syntax for this or at least
show a better way of implementing this.
Hi all,
I am looking to implement a tabbed interface. The tabs are mere
link_to links in the template. All i need to do is, check if a
particular tab has been selected and if it has been selected, set
the :id attribute to 'current'. The css code will take care of the
rest. I know the css works because when i explicitly set the :id =>
'current without any conditions, it shows in the browser.
I have however tried many variations and all are throwing me syntax
errors. Hope someone can give me the right syntax for this or at least
show a better way of implementing this.
@Erol,
Thank you so much! I have been letting this bug me for a couple of
days now and to see your simple solution working is an amazing pick-me-
up!
I think its the simplest tabbed interface code one could hope for.
You might also want to look at link_to_unless_current (and perhaps its
source code) to see how you might change your helper (or abandon it
altogether in some cases).
Thank you Rob.
I actually DID come across these helpers when i was searching around
for solutions. These though provide the link conditionally. If the
condition is not satisfied, the link itself does not exist, it only
renders text. But i need all the links to exist. And only the CSS id
to change conditionally. For which the code above worked like a charm.
Thanks again for your input!