Initializing the State

To use the session storage utilities, you must initialize them in the ready function of your JET model by using the following guidelines:

  • Always call the restore state method if it exists so that when the page is refreshed (or the user returns to the page from another application), the state is restored.
  • Always call the manage state method during the window unload event. This method ensures that the correct action is performed for the state when the page is unloaded.
  • Define a method in your model that applies the state that was restored to the fields on the page.

The following example shows how you can initialize the session storage utilities in the ready function of your JET model:

Example: ready (function ()

$(document).ready(function ()
{
     var model = new Model();
     ko.applyBindings(model, document.getElementById('container'));
     if(typeof jde__restoreState === 'function')
     {
        model.applyRestore(jde__restoreState());
     }        
                
     $(window).bind('unload', function()
     {s
         if(typeof jde__manageState === 'function')
         {
             jde__manageState(model.state);
         }
      });
});
                
      //in the Model
      this.applyRestore = function(restoredObject)
      {
         if(restoredObject)
         {
           this.filterValue(restoredObject.filterValue);
         }
      }