i'm trying save state of collapsible menu, , using jquery cookie plug in .. i'm having trouble far though.. help?
the script collapse/expand
<script type="text/javascript"> $(document).ready(function() { $(".login-holder > ul > .logintitle").click(function() { $(this).parent().find("li").slidetoggle("fast"); if ($(this).parent().find(".toggle").html() == "+") { $(this).parent().find(".toggle").html("-"); } else { $(this).parent().find(".toggle").html("+"); } }); }) </script>
the xhtml
<ul class="account-links"> <div class="logintitle">user options<span class="toggle">-</span></div> <div class="menulinks"> <li> <%= html.actionlink<eventcontroller>( x => x.list(), "events near me" )%> </li> <li> <%= html.actionlink<myeventscontroller>( x => x.list(), "my events" )%> </li> <li> <%= html.actionlink<accountcontroller>( x => x.edit(), "my profile" )%> </li> <li> <%= html.actionlink<clubcontroller>( x => x.list(), "clubs near me" )%> </li> <li> <%= html.actionlink<myclubscontroller>( x => x.list(), "my clubs" )%> </li> <li> <%= html.actionlink<accountcontroller>( x => x.changepassword(), "change password" )%> </li> <li> <%= html.actionlink<dependantcontroller>( x => x.list(), "my dependants" ) %> </li> </div> </ul> </div> <% if ( viewmodel.profile.hasorganizerinfo ) { %> <div class="login-holder"> <ul class="account-links"> <div class="logintitle">organizer details<span class="toggle">-</span></div> <div class=menulinks> <li> <%= html.actionlink<accountcontroller>( x => x.organizer(), "organizer details" )%> </li> <li> <%= html.actionlink<eventcontroller>( x => x.edit( default(int?) ), "post event" )%> </li> <li> <%= html.actionlink<eventadmincontroller>( x => x.list(), "events created me" ) %> </li> <li> <%= html.actionlink<clubcontroller>( x => x.edit( default( int? ) ), "create club" )%> </li> <li> <%= html.actionlink<clubadmincontroller>( x => x.list( ), "clubs created me" )%> </li> </div> </ul> </div> <% } %>
one way i've done using cookies attach unload
handler set cookie - did finding ids of classes not default (whether that's visible or hidden you), , saving them cookie. when page loaded again, check if cookie existed, , if did use string of ids selector apply toggled default
class items saved earlier.
Comments
Post a Comment