Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
170
rated 0 times [  174] [ 4]  / answers: 1 / hits: 22343  / 12 Years ago, fri, november 2, 2012, 12:00:00

I am building a PhoneGap App. Unfortunately, when deploying to iOS devices and simulators the deviceready event never fires. I'm using Phonegap 2.2.0.



When I deploy the same code to Android (using the Android-specific cordova.js file of course) the App will work perfectly.



When I replace the deviceready with a jQuery-ready() the app will load on iOS as well, yet it will then lack access to the device specific APIs.



The cordova.js is loaded as I will see a simple alert message that I put inside of it, yet deviceready never fires and the APIs are never exposed.



My HTMLs head:



<script type=text/javascript charset=utf-8 src=js/cordova.js></script> <!-- yes it is the iOS version -->
<script src=js/jquery-1.8.2.min.js></script>
<script src=js/app.js></script>


My JS:



function doStuff(){
//app functionality
}
document.addEventListener('deviceready', doStuff, false);


But somehow stuff will only get done on Android...


More From » jquery

 Answers
6

in my html I have a onload that triggers that adding of an event listener to deviceready



      function onDeviceReady() {
console.log(we are an app);
MyApp.initialize_phonegap();
}

function onBodyLoad() {
document.addEventListener(deviceready, onDeviceReady, false);
}

</script>

</head>

<body onload=onBodyLoad()>

[#82233] Wednesday, October 31, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daquanmilesw

Total Points: 57
Total Questions: 102
Total Answers: 110

Location: Wallis and Futuna
Member since Sat, Aug 6, 2022
2 Years ago
daquanmilesw questions
;