cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Mueller (Commented) (JIRA)" <>
Subject [jira] [Commented] (CB-551) deviceready is fired every time changePage() is called in jQuery Mobile within a single-page app
Date Fri, 20 Apr 2012 17:54:40 GMT


Patrick Mueller commented on CB-551:

Personally, I avoid all the "external content" stuff when I use jQuery mobile, inline everything,
so not a lot of experience here.

Not sure if this is the problem, but pretty sure there is some way to have jQuery Mobile work
via page reloading - in the case of traversing to a new "page" that is actually external.
 I think you can swizzle it to XHR the content instead, bypassing the need for an actual page

Even in the case of XHRing the content instead of traversing to a new page, if you're updating
location at all, not hard to imagine that might trigger the page reload-y bits of Cordova.
 We may need to kind of bullet-proof this stuff and check to see if Cordova is already loaded
before running through the deviceReady logic.

If jQuery does have a mode of actually reloading pages, then we WILL actually need to re-init
the Cordova bits in the browser again.  But we should do the right thing if they just update
location and the browser doesn't actually reload the page.
> deviceready is fired every time changePage() is called in jQuery Mobile within a single-page
> ------------------------------------------------------------------------------------------------
>                 Key: CB-551
>                 URL:
>             Project: Apache Callback
>          Issue Type: Bug
>          Components: BlackBerry
>    Affects Versions: 1.6.0
>            Reporter: Filip Maj
>            Assignee: Filip Maj
> Taken from
> Single page app. When switching view divs, something triggers deviceready to be called
again. Likely something to do with the {{location.href}} changing. Probably shouldn't be happening.
> Example code:
> {code}
> <!DOCTYPE html>
> <html>
> <head>
> <meta charset="UTF-8">
> <meta name="viewport" id="viewport" content="width=device-width,height=device- height,initial-scale=1.0,user-scalable=no">
> <script src="cordova-1.6.0.js" type="text/javascript"></script> 
> <script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script>
> <link rel="stylesheet" href="jquerymobile/" />
> <script type="text/javascript" src="jquerymobile/"></script>
> <script type="text/javascript">
>     //---------------------------------------------------------------------
>     // Cordova event listeners
>     //---------------------------------------------------------------------
>    function onDeviceReady() {
>     alert("Inside Device Ready");
>     }
>     // register Cordova event listeners when DOM content loaded
>     function init() {
>         console.log('init()');
>         document.addEventListener("deviceready", onDeviceReady, true); 
>     }
> </script>
> <title>Cordova API Sample</title>
> </head>
> <body onload="init()">
>    <div data-role="page" id="home">
> <div data-role="header">
> <h1>Here is the index page.</h1>
> </div>
> <div data-role="content">
> <p><center>Below you may transition to our other pages.</center></p>
> <a href="#about" data-ajax="false" data-role="button" data-inline="true">About
> </div>
> </div>
> <div data-role="page" id="about">
> <div data-role="header">
> <h1>About Us</h1>
> </div>
> <div data-role="content">
> <a href="#home" data-ajax="false" data-role="button" data-inline="true">Back Home</a>
> </div>
> </div>
> </body>
> </html>
> {code}

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message