Skip to content Skip to sidebar Skip to footer

Saving State Of Menu After Page Reload

I have treeview menu where I would like to remember its state after page reloads. To reload page I'm using angularJS function $state.reload(); I don't know should I use Jquery to

Solution 1:

It sounds like cookies are what you want here. Check out this W3C spec on cookies, no jQuery required!

Once you save the cookie, after a page reload just check the state of the cookie and display the menu based on that

Solution 2:

I think your best option will be to consider using window.localStorage with a cookie fallback. In fact, if you are using angular you may even consider using angular-local-storage which can be seen here.

angular-local-storage provides the cookie fallback for you but this isn't too hard to implement yourself and just requires a check for whether window.localStorage is defined.

Hope that helps you out!

Post a Comment for "Saving State Of Menu After Page Reload"