cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Grieve (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-2166) The deviceReady event may not be received because of asynchronous JavaScript loading
Date Tue, 16 Apr 2013 13:43:15 GMT

    [ https://issues.apache.org/jira/browse/CB-2166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13632837#comment-13632837
] 

Andrew Grieve commented on CB-2166:
-----------------------------------

There's now a pull request for this: https://github.com/apache/cordova-js/pull/31
                
> The deviceReady event may not be received because of asynchronous JavaScript loading
> ------------------------------------------------------------------------------------
>
>                 Key: CB-2166
>                 URL: https://issues.apache.org/jira/browse/CB-2166
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaJS, Docs
>    Affects Versions: 2.2.0
>         Environment: Cordova 2.2, Android 2.3.4
>            Reporter: Thomas Dinger
>            Assignee: Filip Maj
>
> HTML page includes Cordova script first, then my Cordova-dependent script. My script
registers a listener for the deviceReady event. Occasionally the listener is not called. I've
determined the problem is due to the timing of the asynchronous loading of the script files.
Because of the way cordova "hijacks" the document.addEventListener function, my event handler
may be registered with the document object instead of Cordova, depending on whether the Cordova
script is executed before my script.
> Would it be possible for Cordova to look at the document object and determine whether
there are existing event listeners for the deviceReady event? And if there are, to "hijack"
these event handlers so they are called correctly when Cordova sends the deviceReady event?
> I have changed my code to wait for the DOMContentLoaded event before registering my deviceReady
event handler. This has been successful for me, and might be an approach that could be used
in the Cordova documentation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message