javascript - PhoneGap Device ready not firing in ios but working fine in android emulator and ripple -
hey guys have problem firing deviceready on ios, code work find on adnroid emulator , ripple dont know problem. didnt try on readl android device emulator works fine, have tried on iphone 5 never call device ready.i have question true there different js files cordova different platforms ?
var devicereadydeferred = $.deferred(); var jqmreadydeferred = $.deferred(); document.addeventlistener("deviceready", deviceready, false); document.addeventlistener("resume", deviceresume, false); function deviceresume() { dowhenbothframeworksloaded(); } function deviceready() { devicereadydeferred.resolve(); } $(document).one("mobileinit", function() { jqmreadydeferred.resolve(); }); $.when(devicereadydeferred, jqmreadydeferred).then( dowhenbothframeworksloaded); function dowhenbothframeworksloaded() { var networkstate = navigator.connection.type; var states = {}; states[connection.unknown] = 'unknown connection'; states[connection.ethernet] = 'ethernet connection'; states[connection.wifi] = 'wifi connection'; states[connection.cell_2g] = 'cell 2g connection'; states[connection.cell_3g] = 'cell 3g connection'; states[connection.cell_4g] = 'cell 4g connection'; states[connection.cell] = 'cell generic connection'; states[connection.none] = 'no network connection'; if (networkstate == connection.none) alert('you have connected internet in order use app.'); else { settimeout(function(){ $.mobile.changepage("deals.html", { transition : "pop", reverse : false, changehash : false }); },1000); } } <!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>phonegap</title> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script type="text/javascript" charset="utf-8" src="cordova-2.6.0.js"></script> <script type="text/javascript" charset="utf-8" src="pushnotification.js"></script> <script type="text/javascript" charset="utf-8" src="js/jquery.min.js"></script> <script type="text/javascript" charset="utf-8" src="controller/index.js"></script> <script type="text/javascript" charset="utf-8" src="js/jquerymobile.js"></script> <script type="text/javascript" charset="utf-8" src="js/handlebars.js"></script> <script type="text/javascript" charset="utf-8" src="js/handlehelpers.js"></script> <script type="text/javascript" charset="utf-8" src="js/jquery.timeago.js"></script> <link rel="stylesheet" href="css/jqm.css" charset="utf-8" /> <link rel="stylesheet" href="css/style.css" charset="utf-8" /> </head> <body> <div class="container splash" data-role="page" id="index"> <img src="img/logo.png" /> </div> </body> </html>
in order use phonegap along jquery mobile, need use this,
$(document).one("mobileinit", function() { $.support.cors = true; $.mobile.allowcrossdomainpages = true; jqmreadydeferred.resolve(); });
Comments
Post a Comment