Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onDeviceReady() doesnt get called when page is reloaded?

I am using PhoneGap (Cordova-1.5.0.js) and I am running into this issue:-

I have a status page which shows multiple records(after firing an ajax call). When I click on any one record, it goes to the details page where it fires an ajax call to get the details of the record and displays it.

The funny thing is, If I go back to the status page(using navigator.app.backHistory()) and select some other record to see its details, it again goes to the details page BUT THIS TIME IT DOESNT FIRE THE AJAX CALL. It also doesnt fire the onDeviceReady() method.

For navigation from status page to details page, I use following on the onClick event of the div which I click:-

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

Oh and btw, I am using iScroll 4 as well. All used to work fine earlier and these problems cropped up after i included iScroll 4 in my project.

Thanks in advance.

like image 901
Vibhas Zanpure Avatar asked Nov 21 '25 12:11

Vibhas Zanpure


1 Answers

onDeviceReady is only supposed to fire once - when the first page is loaded and the PhoneGap framework is initialised.

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

EDIT

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

This will make sure PhoneGap is not loaded every time you navigate to a new page. Loading it is time consuming and should only be done once for an app.

like image 54
codemonkey Avatar answered Nov 24 '25 04:11

codemonkey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!