Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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

});

}

});

0 Replies