Page 1 of 1

unload a page

Posted: Sat Jun 07, 2014 2:19 pm
by Terry Gilliver

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


unload a page

Posted: Sat Jun 07, 2014 4:29 pm
by Igor

Hello,

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


unload a page

Posted: Sun Jun 08, 2014 11:40 am
by Terry Gilliver

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


unload a page

Posted: Mon Jun 09, 2014 10:14 am
by Kateryna Grynko

Hi Terry,

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