我正在使用JQuery Mobile 1.4.5和Phonegap(Build),并且在第一页上没有触发任何页面事件'该应用程序,pageshow
除外...这非常不方便,因为我需要将事件绑定到pagecreate
。
你知道发生了什么吗?
由于
在Html中我试图添加一个假冒的'第一页:#start-page。
HTML:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<div id="container">
<div id="start-page" data-role="page" data-title="App Title">
</div>
<!-- WEIGHT-LEVEL PAGE -->
<div id="weightlevel-page" data-role="page">
...
</div>
<div id="compute-page" data-role="page">
...
</div>
</div> <!-- container -->
</body>
</html>
JS:
var isPhoneGap;
var deviceReadyDeferred = $.Deferred();
var jqmReadyDeferred = $.Deferred();
isPhoneGap = checkIfPhoneGap();
if ( isPhoneGap ) {
$.when(deviceReadyDeferred, jqmReadyDeferred).done( Everything );
} else {
console.log("NOT Running on PhoneGap!");
$.when(jqmReadyDeferred).done( Everything );
}
$(document).on("mobileinit", function () {
//alert('mobileinit just fired');
//popShortToast("mobileinit just fired");
//FastClick.attach(document.body);
$.mobile.pageContainer = $('#container').pagecontainer();
jqmReadyDeferred.resolve();
});
function onDeviceReady() {
//popShortToast("deviceReady just fired");
deviceReadyDeferred.resolve();
}
document.addEventListener("deviceReady", onDeviceReady, false);
function Everything() {
todoDuringSplashPage(); //this is where I preprocess the app : retrieving the database from the server, preparing arrays/variables, etc. When it's done, I move to the first page using : $.mobile.pageContainer.pagecontainer("change", "#weightlevel-page", { transition: "fade" });
$(document).on('pagebeforecreate', '#weightlevel-page', function(){ alert('pagebeforecreate on #weightlevel-page'); });
$(document).on('pagecreate', '#weightlevel-page', function(){ alert('pagecreate ($(document).on) on #weightlevel-page'); });
$('#weightlevel-page').on('pagecreate', function(){ alert('pagecreate on #weightlevel-page'); });
$(document).on('pageinit', '#weightlevel-page', function(){ alert('pageinit on #weightlevel-page'); });
$(document).on('pagebeforeshow', '#weightlevel-page', function(){ alert('pagebeforeshow on #weightlevel-page'); });
$(document).on('pageshow', '#weightlevel-page', function(){ alert('pageshow on #weightlevel-page'); });
$(document).on('pageload', '#weightlevel-page', function(){ alert('pageload on #weightlevel-page'); });
}
我正在使用启动画面:
$.mobile.pageContainer.pagecontainer("change", "#weightlevel-page", { transition: "fade" });
但是每个页面事件都会在桌面上触发。