I am trying to make my app (which uses Jquery Mobile 1.4) able to run
either as a Phonegap app (using Phonegap Build, not Xcode)
or as a pure webapp on a standard browser by starting my js file like below.
But none of the Jquery Mobile events are bound...
Can you help me see why ?
var deviceReadyDeferred = $.Deferred();
var jqmReadyDeferred = $.Deferred();
$(document).one("mobileinit", function () {
console.log('mobileinit just fired');
jqmReadyDeferred.resolve();
});
document.addEventListener("deviceReady", onDeviceReady, false);
function onDeviceReady() {
deviceReadyDeferred.resolve();
}
if ( isPhoneGap() ) {
alert("isPhoneGap yes");
$.when(deviceReadyDeferred, jqmReadyDeferred).then( EVERYTHING );
} else {
console.log("NOT Running on PhoneGap!");
$.when(jqmReadyDeferred).then( EVERYTHING );
}
function EVERYTHING() {
//all the JQM bindings here:
$(document).on('pagecontainershow', function (e, ui) {
//...
});
$(document).on('pagecreate','#splash-page', function(){
//...
});
$(document).on('pagecreate','#faq-page', function(){
//...
});
//etc.
}
PS: I use the function isPhoneGap from here and this works fine.