Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

unload a page

I have a page which is rendered on page load, based on a local storage variable. It works fine until I navigate back to a previous page and change the storage variable, the idea being that when the page is loaded again, it will be rendered differently. The problem is that the load event doesn't fire the second time round. i am guessing that it is because the page is aleady loaded. and I could possibly fix this by unloading the page before it goes back to the previous page, thus forcing it to reload when it is navigated to again.

How do I unload a page in javascript?

Thanks,

Terry

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

unload a page

Hello,

Please try to use page show event instead of page load event.
http://devcenter.appery.io/documentat...

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

unload a page

I have tried using the page show event but this does not allow me to create my service object. See the js below:

pre
//Set Page Title
var title = localStorage.getItem('category').trim();
console.log("The category is now " + title);
(Appery('itemsHeader').text(title));

//parse title
strippedTitle = title.replace(/\s+/g,'');
strippedTitle = strippedTitle.toLowerCase();
console.log("'parsed title = " + strippedTitle + "'");

//construct service name
serviceName = strippedTitle + "_items_list";
console.log("'Service Name = " + serviceName + "'");

//if I use the page show event, the following line fails, but works on page load
serviceName = this[serviceName.trim()];

console.log("'Service Name (object) = " + serviceName + "'");

//Execute search service
serviceName.execute({});
/pre

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

unload a page

Hi Terry,

Use this code to access a service on Page Show event:preserviceName = window[serviceName.trim()];/pre

Return to “Issues”