Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phonegap deviceready event - ripple emulator

Tags:

cordova

hello all
Im having some problems with the initial phonegap 'deviceready' event-handler not being triggered properly, in the ripple chrome extension phonegap emulator.

<script src="xui-2.0.0.js" type="text/javascript" charset="utf-8"></script> 
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<!--
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
-->
<script type="text/javascript" charset="utf-8" src="phonegap.0.9.4.js"></script>
<!-- <script type="text/javascript" charset="utf-8" src="main.js"></script> -->
<script>
    function onLoad() {
        //console.log(document);
        /*document.addEventListener('deviceready',function() {
                console.log('PHONEGAP_READY');
            },false);*/
        console.log('ON_LOAD');
        x$(document).on('deviceready', function() {
                console.log('PHONEGAP_READY');
            }, false);
    }

</script>

so the issue is that the console.log('PHONEGAP_READY') is never run. I used XUI here just to try the way the official ripple phonegap demos work (ones posted on their page). neither that, nor the document.addEventListener(), work... whats strange is that the chrome console output reads "PhoneGap :: fired deviceready event!" so Im assuming the event really is firing, but the event handler itself is not being called...
any clues are appreciated

thanks

like image 961
deepblue Avatar asked Mar 03 '11 21:03

deepblue


3 Answers

There is a quirk in how ripple emulates the runtime for phonegap: docs here

ripple will inject the phonegap runtime before the document loads and if you include the phonegap.js file in your app it will override the ripple emulated environment and that may cause issues.

Try removing the phonegap source from your page and reloading to see if that helps.

like image 176
Gord Avatar answered Oct 19 '22 15:10

Gord


I've spent hours trying to fix this as well. What will help is manually setting the Cordova Platform version to 2.0 in the Ripple UI (Left pane > Platforms > Version: change from 1.0 to 2.0). It's quite silly, I was calling Ripple with this URL

http://localhost?enableripple=cordova-2.7.0-Nexus4 

but I still had to change the settings manually to finally get it to run. That's because Ripple doesn't know any version higher than 2.0.0, which makes it simply set the platform version to 1.0.0 in the UI... and then it just uses that.

More details also on my blog.

like image 35
Irina Anastasiu Avatar answered Oct 19 '22 16:10

Irina Anastasiu


try http://localhost:8080/index.html?enableripple=cordova-2.0.0, this works for me to fire deviceready event

like image 5
user2152735 Avatar answered Oct 19 '22 14:10

user2152735