cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Grieve <agri...@chromium.org>
Subject Re: OnDeviceReady with unstable behaviour
Date Thu, 14 Aug 2014 14:09:05 GMT
Hmm, good point. I have no guesses now :(


On Wed, Aug 13, 2014 at 10:25 PM, Terence M. Bandoian <terence@tmbsw.com>
wrote:

> Right. The docs also include the following:
>
> "The deviceready event behaves somewhat differently from others. Any event
> handler registered after the deviceready event fires has its callback
> function called immediately."
>
> -Terence
>
>
>
> On 8/13/2014 8:29 PM, Joe Bowser wrote:
>
>> When subscribing to the events, it should actually run right away if the
>> event was already fired. This is definitely a regression in cordova.js, or
>> a design change I didn't catch. Both are possible.
>> On Aug 13, 2014 5:59 PM, "Terence M. Bandoian" <terence@tmbsw.com> wrote:
>>
>>  Same on http://cordova.apache.org/docs/en/3.5.0/cordova_events_
>>> events.md.html#deviceready.
>>>
>>> -Terence
>>>
>>>
>>> On 8/13/2014 7:51 PM, Terence M. Bandoian wrote:
>>>
>>>   From the phonegap 3.5.0 docs:
>>>>
>>>> <!DOCTYPE html>
>>>> <html>
>>>>    <head>
>>>>      <title>Device Ready Example</title>
>>>>
>>>>      <script type="text/javascript" charset="utf-8"
>>>> src="cordova.js"></script>
>>>>      <script type="text/javascript" charset="utf-8">
>>>>
>>>>      // Wait for device API libraries to load
>>>>      //
>>>>      function onLoad() {
>>>>          document.addEventListener("deviceready", onDeviceReady,
>>>> false);
>>>>      }
>>>>
>>>>      // device APIs are available
>>>>      //
>>>>      function onDeviceReady() {
>>>>          // Now safe to use device APIs
>>>>      }
>>>>
>>>>      </script>
>>>>    </head>
>>>>    <body onload="onLoad()">
>>>>    </body>
>>>> </html>
>>>>
>>>> -Terence
>>>>
>>>>
>>>> On 8/13/2014 3:52 PM, Carlos Santana wrote:
>>>>
>>>>  Like Andrew mentioned too late to add the listener.
>>>>>
>>>>> Where are you putting your cordova.js? If you are loading it from
>>>>> <head>
>>>>> then device ready is firing before you attach.
>>>>>
>>>>> To be on the super safe side attach the listener  before you load
>>>>> cordova.js in body, to be on the safe side.
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Aug 13, 2014 at 2:40 PM, Andrew Grieve <agrieve@chromium.org>
>>>>> wrote:
>>>>>
>>>>>   My guess: Don't wait until onload to register your deviceready
>>>>> listener.
>>>>>
>>>>>>
>>>>>> On Wed, Aug 13, 2014 at 1:43 PM, Leonardo Martínez <
>>>>>> leolib2004@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>   Hi,
>>>>>>
>>>>>>> I am new here and I got into this mailing list because of this
>>>>>>> strange
>>>>>>> behaviour.
>>>>>>>
>>>>>>> The thing is that sometimes the ondeviceready event is not triggerred
>>>>>>> and
>>>>>>> sometimes it is. I could say like the first time the windows
is
>>>>>>> opened
>>>>>>> (window.open("...") ) it is not triggered but going back (to
another
>>>>>>> window) and in again it's triggered.
>>>>>>>
>>>>>>> I have this in the HTML:
>>>>>>>
>>>>>>> <body onload="onLoad()">
>>>>>>>           <div id="mainDiv">
>>>>>>>               <div id="deviceready" class="blink">
>>>>>>>                   <p class="event listening">Connecting
to Device</p>
>>>>>>>                   <p class="event received">Device is Ready</p>
>>>>>>>               </div>
>>>>>>>
>>>>>>> ....
>>>>>>> </body>
>>>>>>>
>>>>>>> And this function in JS:
>>>>>>>
>>>>>>> function onLoad() {
>>>>>>> document.addEventListener("deviceready", onDeviceReady, false);
>>>>>>> alert("I was set");
>>>>>>> }
>>>>>>>
>>>>>>> function onDeviceReady() {
>>>>>>> alert("Hi");
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> I am working with Cordova 3.5.0-0.2.4 and this is happening in
iOS.
>>>>>>> Not
>>>>>>>
>>>>>>>  on
>>>>>>
>>>>>>  Android with the same code.
>>>>>>>
>>>>>>> Hope you can help me. Thanks!
>>>>>>>
>>>>>>> --
>>>>>>> Leonardo.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message