首先,您应该将点击功能更改为:
$('._jsClick').on('click', function(event) {
alert('Hi!')
});
你也应该:
$('div:jqmData(role="page")').on('pagebeforeshow', function(){
$('._jsClick').on('click', function() {
alert('Hi!')
});
});
$('div:jqmData(role="page")').live('pagebeforeshow', function(){
$('._jsClick').on('click', function() {
alert('Hi!')
});
});
未准备好文档
检查此链接:如何让 jquery mobile "pagebeforeshow" 事件每次都触发,而不仅仅是 refresh。上面的代码会在被调用时$.mobile.changePage
被调用。
这应该是这样的:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
navigator.geolocation.getCurrentPosition(onSuccess, onError);
$('div:jqmData(role="page")').die('pagebeforeshow');
$('div:jqmData(role="page")').live('pagebeforeshow', function(){
$('._jsClick').off('click');
$('._jsClick').on('click', function() {
alert('Hi!')
});
});
}