php - Bootstrap - How to save the state of collapse in a SESSION -


I use bootstrap and I would like to save the current session's status (open or closed) in session variable PHP cookie In)

Can you give me: - An example code to save the current session in session variable PHP.

First of all, do you really need to store it in session? Does some PHP script work with that value?

Both cases:

You will need to store the location of the stacked items somewhere in the javascript variable:

 < Code> var collapsed = false; // Default value $ ('Fall'). ('Hide.bs.collapse', function () {collapsed = true; // hide, true is collapsed}) $ ('fall'). ('Show.bs.collapse', function () {on the show, framed is false on = false; // show}}   

Yes, let me save it in session To do this:

On each request, you must add the collapsed variable and give it a trough GET method for example:

  $ ('a ')' Moushudown ', function () {var c = collapsed? 1: 0; var href = $ (this) .attr (' href '); if (href.indexOf ('? ')! == -1 ) {$ (This) .attr ('href', href + 'and collapsed =' + c); and {$ (this) .attr ('href', href + '? Collapsed =' + c); }}});   

and somehow save it in session

  $ _ session ['abbreviated]] = $ _GET [' short ']; No, I do not have to store in the session:   

Most modern browsers now have local storage variables, which are similar to sessions Something is in javascript

Save in the variable (for instance in the event handler):

  if (typef!) == "undefined") {window.localStorage.setItem (' Collapsed ', collapsed); // does not save any end code SessionStorage.setItem ('collapsed', collapsed); // saves until the browser is closed} and {// Sorry! Some startup support ..}   

Load some startup scripts:

  if (typeof (storage)! == "undefined") {collapsed = Window .localStorage.getItem ('Collapsed'); // Select a brief = code.sessionStorage.getItem ('collapsed') again; If (collapsed) {$ ('Fall'). Fall ('show'); } And {$ ('Fall.') Fall ('hide'); }} And {sorry! There is no storage support.}   

There may be other solutions, but these can only be considered by me. :)

All codes need jQuery

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -