0

Trying to use collapse-menu to open sub-menu on my sidebar. I'm trying to list everything in the menu on the first click, and then open a sub-menu through a collapse-menu. But it's closed when the page refresh.

Does anyone know how I could solve that?

Siguza
  • 21,155
  • 6
  • 52
  • 89
  • 1
    possible duplicate of [Retain Twitter Bootstrap Collapse state on Page refresh/Navigation](http://stackoverflow.com/questions/12733238/retain-twitter-bootstrap-collapse-state-on-page-refresh-navigation) – Leistungsabfall Oct 02 '14 at 20:17
  • [bootstrap collapsible](http://cssdeck.com/labs/twitter-bootstrap-plain-collapsible-tree-menu) – alessandrio Oct 02 '14 at 20:18

1 Answers1

0

I'm assuming you're relying on front end tools. When you refresh, you will load the same HTML/CSS/JavaScript every time. Therefore, you will always have your original settings. You can make the collapse default (everytime you go under a certain width, the menu/bar collapses and has to be clicked/toggled to be uncollapsed). This is a pretty standard for collapsable navbars. However, if you want to be able to go beneath a certain width while not collapsed is the default, have the user toggle it, and save that collapsed status, then you need something more than just JavaScript/HTML/CSS.

If you use php, you could save a session status./cookie as collapsed, whenever the toggle is clicked, and then on reload, the menu would collapsed. Basically, you need a backend language to store a cookie or session.