Jason
Jason

Reputation: 1542

Ripple + Phonegap - deviceready not firing

just installed latest versions of phonegap & ripple on Windows7 using npm install.

I run ripple emulate from my project directory to launch ripple in Chrome.

http://localhost:4400/?enableripple=cordova-3.0.0

But I'm getting a file not found on cordova.js and my deviceready event is not firing.

GET http://localhost:4400/cordova.js 404 (Not Found) 

Project is running jquery mobile 1.4.4 with jquery 1.11.1.

This is what my js looks like in my footer. How do I fix this and get my deviceready event firing?

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="css/vendor/jquery-mobile/jquery.mobile-1.4.4.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/custom.js"></script>
<script type="text/javascript" src="js/index.js"></script>

<script type="text/javascript">
   app.initialize();
</script>

Testing Device Ready with the following js.

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
    // Now safe to use the Cordova API
    console.log("Device Ready");
}

Upvotes: 2

Views: 1557

Answers (1)

Jason
Jason

Reputation: 1542

Got it working. I copied cordova.js and cordova_plugins.js from

[APP-DIR]\platforms\android\assets\www

into

[APP-DIR]\www

That solved the 404's on the two js files. And then both of these worked inside my custom.js file to capture the deviceready event.

document.addEventListener("deviceready", function(){
        console.log("Device Ready!!!");
 },true);


document.addEventListener("deviceready", callMe, false);

function callMe() {
    // Now safe to use the Cordova API
    console.log("Call ME!");
}

Upvotes: 2

Related Questions