Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm building a accordion menu and I'm trying to keep the last active state of the accordion on page reload. I've tried javascript (see below) but it doesn't seem to work.

See Codepen here

$(document).ready(function () {
$('.b-accordion').accordion({
header: '.b-accordion__cell',
collapsible: true,
activate: function(e, ui) {
localStorage.setItem('accordion-active', $(this).accordion( "option", "active" ));
},
active: +localStorage.getItem('accordion-active')
});
});


Any help would be appreciated. Thank you!
Posted
Comments
Sinisa Hajnal 18-Jan-16 5:59am    
I resolved mine by saving current index in session (but I had server round trip so I could do it). If this is jQuery, Wasn't there a property that saves the state in newer versions?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900