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: 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: and somehow save it in 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): Load some startup scripts: There may be other solutions, but these can only be considered by me. :) All codes need jQuery < 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}}
$ ('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); }}});
$ _ session ['abbreviated]] = $ _GET [' short ']; No, I do not have to store in the session:
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 ..}
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.}
Comments
Post a Comment