javascript - Using jQuery Mobile and $(document).ready with PhoneGap Build and document.addEventListener("deviceready") -
i've been through solutions in 2 questions related - jquery document.ready vs phonegap deviceready , correct way of using jquery-mobile/phonegap together? , still no closer solution.
our issue phonegap build plugins. we're using device plugin target specific ui component positions , sizes iphones 4 , 5. in doing need phone call event listener, utilize device plugin device model, set variable (iosversion = true) , utilize variable when build ui.
we can't working.
we're using jquery mobile in
$(document).ready(function(
this has
document.addeventlistener("deviceready", false);
in it, rest of our scripts , ui initialisation scripts. jqm template, we're building content , ui components based on json data. until point it's been fine.
the problem ui initialisation script seems start before event listener has finished doing whatever , iosversion never, ever true time ui script runs.
yes, phone call ondeviceready in:
document.addeventlistener("deviceready", ondeviceready, false);
but can't test in browser.
i'm sure there simple solution i'm missing, we've been @ day , it's final hurdle , has got frustrated.
i got answer.
window.cordova exposed in phonegap build. check existence of this, in jquery $(document).ready this:
if ( !!window.cordova ) { // phonegap script has loaded have our // initializeapplication called when device ready document.addeventlistener("deviceready", initializeapplication, false); } else { // running in browser without phonegap // manually phone call initializeapplication initializeapplication(); } function initializeapplication() { // here initialize // application , ui }
javascript jquery jquery-mobile cordova phonegap-build
No comments:
Post a Comment