Jump to content

Accordion Save State After Referesh


demeritrious

Recommended Posts

Any help on this would been very much appreciated. I am trying find a way to save the state of the JQuery accordions on my webpage after a user refreshes or changes webpages within my website. I have tried installing different scripts and downloading different cookie plugins but they either don't work or breaks all of the jquery functions on my webpage. Thank you.

 

 

This is in my header 

<head>
<link rel="stylesheet" type="text/css" href="css/styles.css">
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css">
<script src="js/jquery.js"></script>
<script src="js/jquery-ui.js"></script>
<script type="text/javascript" src="Cookies/jquery.cookie.js"></script>
</head>

My Html

<div id="History">
<!---Images---> 
<p>Today In History</p>
<div>       
<script type="text/javascript" src="http://rss.brainyhistory.com/link/historyevents.js"></script><small><i>more <a href="http://www.brainyhistory.com/" target="_blank">History</a></i></small>
</div>
</div>

This is my original JQuery code

$( "#History" ).accordion({
collapsible: "true",     
heightStyle: "content"
});
Link to comment
https://forums.phpfreaks.com/topic/290399-accordion-save-state-after-referesh/
Share on other sites

You'd have to either use the new html5 local storage method and have an if() in your jquery to check the status of that OR do the same kind of method with php sessions.  The later will require an ajax call to set the session everytime they select a accordion option.

  On 8/11/2014 at 7:41 PM, demeritrious said:

I have no idea how to do either. Is there a script or demo that you know of?

 

It's not easy, and it's a native-JS tutorial, but it is described here. On the other hand, it uses cookies, which would be easier than the PHP method.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.