jquery - Javascript static variables and using in different pages -


i have jquery plugin in layout page header:

<script src="@url.content("~/scripts/js/kendo.web.min.js")"></script> <script src="@url.content("~/scripts/app/jscommon.js")"></script> <script src="@url.content("~/scripts/app/layout.js")"></script> 

and layout.js:

    (function ($) {     var layout = function (node, options) {         this.node = node;         this.options = $.extend({             url: ""         }, options);         $(this.node).find('.hbutton').bind('click', $.proxy(this.hbuttonclicked, this));     };      layout.prototype = {         constructor: layout,         _loadbackground: function () {             debugger;             //load second 'common.currenttarget' have been lost             $(common.currenttarget).removeclass();             $(common.currenttarget).addclass(".hbutton_selected");         },          hbuttonclicked: function (e) {             debugger;             //load first             common.currenttarget = e.currenttarget;         }     }      $.fn.layout = function (options) {         return this.each(function () {             $(this).data('layout', new layout(this, options));         });     };  }(jquery)); 

in other side have share repository javascript object :

function common() {   }  common.currenttarget = null;  var common = new common(); 

then in other page i've triggered event following :

<script>   $(document).ready(function () {     var layout = $("#layout").data("layout");     $(layout).trigger("_loadbackground")   }); </script> 

when hbutton element click happened @ first i'm writing object inside "common.currenttarget" , saved when i've watched variable when page loads , trigger event "_loadbackground" value of "common.currenttarget" have been lost, question how can define static variable permanent in whole of pages?

you can set cookie javascript store data, , access cookie page. cookies can persist during browser session, or can give them expiration. html5, there local storage.


Comments

Popular posts from this blog

Line ending issue with Mercurial or Visual Studio -

java - Jtable duplicate Rows -

java - Run a .jar on Heroku -