Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

apq
New Contributor II

Simple multipage mashup solution using Local storage

Hi,

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 );

});

}

});

Community Browser