OnDeviceReady () not called on page reload?

I am using PhoneGap (Cordova-1.5.0.js) and I am facing this problem: -

I have a status page that shows multiple entries (after starting an ajax call). When I click on any one entry, it goes to the detail page where it makes an ajax call to get the post information and display it.

The funny thing is, if I go back to the status page (using navigator.app.backHistory ()) and select another entry to see its details, it goes back to the details page BUT IT'S TIME THAT IT DOESN'T MUST AJAX CALL. It also doesn't fire the onDeviceReady () method.

To navigate from the status page to the detail page, I use the following in the onClick event for the div I click on: -

window.location="record_detail.html?userid=" + userID;

      

Oh and btw, I am also using iScroll 4. Everything worked fine before and these issues came after I included iScroll 4 in my project.

Thanks in advance.

+3


source to share


1 answer


onDeviceReady only needs to fire once β€” when the first page is loaded and the PhoneGap framework is initialized.

If you want to do something every time the page is loaded use the appropriate Javascript load event.

EDIT



You shouldn't use window.location, you should instead use navigator.app.loadUrl ('');

This will cause PhoneGap to not load every time you navigate to a new page. The download is time consuming and only needs to be done once per application.

+1


source







All Articles