Fredrik Thuresson wrote:
Alex Nobert wrote:
> I have a link_to_remote that updates the content of a hidden div and
> makes it appear.. But I want it to hide the div and not execute the
> link_to_remote function on the second click. What's the best way to do
> this? I'm thinking I can do it in RJS maybe, but I'm not sure if
> there's a nice Rails-y way to tell if a div is hidden or not..
> I'd also need to conditionally do the :loading and :success effects
> (show/hide spinner)
Anyone ever come up with a good solution for this. I assume this is very
common for users toggling detail information for list where they want to
load the data on the first click, but just remove it on the second and
I just use two links that do two different things: the first link loads
and displays the new content, and the second link hides the content.
But you only display one link at any one time, so if they're in the
same place it just looks like one link that's changing from "Show" to
"Hide" or whatever.
So when you click on the "Show" link, as well as loading and displaying
the new content, it hides itself and displays the second link. And when
you click on the "Hide" link that's just been revealed, as well as
hiding the new content, it also hides itself and re-displays the first
The way I look at it is that you've got two fundamentally different
actions going on, so you might as well use two different links.