Cordova – phonegap deviceready event – ripple emulator

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

Best Answer

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.

Related Topic