0 Replies Latest reply: Apr 19, 2018 1:48 AM by David Dormvik RSS

    Simple multipage mashup solution using Local storage

    David Dormvik



      I thought I'd share an idea I had for mashups with multiple pages. As is, the websocket closes as the user navigates and the session with its selections are gone. The idea is to save the selection state as the user navigates and then apply it to the new session. I solve this using the browser Local Storage.


      //Saves selections to local storage when user navigates away from page

      window.onbeforeunload = function(){

      app.getList("SelectionObject", function(reply) {

      localStorage.setItem("selections", JSON.stringify(reply.qSelectionObject.qSelections))




      //Loads and applies selections from local storage on document ready.

      $(function() {

      var selections = JSON.parse(localStorage.getItem("selections"));

      if( selections.length > 0 ) {

      selections.forEach( function(selection) {

      app.field(selection.qField).selectMatch( selection.qSelected, true );