Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-491

cordova-1.6.0 + jquery/zepto $(document).bind("deviceready") does not work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 1.6.0
    • None
    • cordova-js
    • Tested on iOS 5.1

    Description

      With Phonegap1.4 or 1.5, I have been OK with the code below, but now I stuck.
      Anyone has an idea? Thanks.
      <html>
      <head>
      <meta name="viewport" content="width=device-width,
      initial-scale=1.0, maximum-scale=1.0, user-scalable=no;"/>
      <meta charset="utf-8">

      <script type="text/javascript" charset="utf-8"
      src="js/cordova-1.6.0.js"></script>
      <script type="text/javascript" src="js/jquery.min.js"></script>
      <script type="text/javascript">

      $(document).ready(function()
      {
      alert("this Alert fires OK");

      $(document).bind("deviceready", function()

      { alert("Got the Error and this Alert Never fires"); }

      );

      });

      </script>

      </head>
      <body>
      <p id="deviceProperties" style="font-size: 20px"></p>
      </body>
      </html>

      (by KenOKABE on https://groups.google.com/forum/?hl=en?hl%3Den&fromgroups#!topic/phonegap/TImcr9kzlq0)

      Possible solution-->

      Hello, I had the same problem with the upgrade from 1.5 to 1.6...

      After a long day I found that that deviceready event begins a little "freak", try changing:

      $(document).bind("deviceready", function()

      { //code });

      by:

      document.addEventListener("deviceready", function()
      { //code }

      , false);

      It worked for me, even so, the most weird thing is that other events like touchmove or orientationchange still works with $( document ).bind; even $( document ).ready function works....

      Appears to fail only with deviceready PG/CV event....

      (by Moisés Gramary Barbosa on same thread)

      Attachments

        Activity

          People

            filmaj Filip Maj
            mowcixo Moisés Gramary
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified