使用电话间隙创建事件加载页面时出现问题



在我的应用程序"index.page"中,我正在标签中加载Phonegap和jqm脚本。我的索引页面中有一个链接,如下所示

<div>
    <a href="page2.html" data-ajax=false;>Click here</a>
</div>

如果我在我的索引页面中单击上面的 url,它会重定向到该页面中的"page2.html",我将完全从上到下加载新鲜的 html。在"page2.html"head标签中,相同的脚本phonegap和JQM js文件在那里。但是当页面在页面创建事件中加载时,它不起作用。找到下面的页面创建我遇到的事件。

$("#page2").live('pagecreate', function(event){
     console.log("Inside page create", device.platform);
});

当页面从页面创建加载时,会出现以下错误。

device is not defined
console.log("Inside page create", device.platform);

如何在 pagecreate 中完全加载页面,并希望在此 pagecreate 中调用一些函数调用。

如果可能的话,不要将jQuery移动事件与phonegap混合使用。

请改用这个:

document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
function onDeviceReady() {
    alert(device.version);
}

最新更新