Forum: Ruby on Rails Toggle css for display on page load?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0f23274e975611727e4ad46d745d298e?d=identicon&s=25 Bill (Guest)
on 2006-06-06 11:23
In my layout I have a navigation bar with a few elements in it.  The
elements can be toggled on or off and thereby reveal or conceal some
subtopics.  I store the state of the toggle for the navigation elements
in the session.

When the page is reloaded, the navigation items are collapsed because
the css for display: none is set by default in the html for the
navigation elements.  Is there a good way to pull the state of the
navigation elements from the session and reset the default css?  I'd
like to restore the navigation to the way the user left it.

Thanks.
Eeba234182bcbd7faed9ff52e233394d?d=identicon&s=25 Douglas Livingstone (Guest)
on 2006-06-06 12:17
(Received via mailing list)
2006/6/6, Bill <devaulw@onebox.com>:
>
If you stored the data about which views were open in cookies (rather
than sessions, which inly stores a session id in the cookie) then you
could use Javascript to read the cookies onload:
http://www.quirksmode.org/js/cookies.html

Douglas
36958dd94ca666a38483df282a5214d5?d=identicon&s=25 Pete (Guest)
on 2006-06-07 14:36
(Received via mailing list)
you need to asynchronously update the session contents using ajax
requests on expand and collapse.

pseudocode

expand -> send ajax request -> session[:state][:node_id] = true
collapse -> send ajax request -> session[:state][:node_id] = nil




Bill schrieb:
This topic is locked and can not be replied to.