我在html页面中有以下代码来创建Menu。当用户点击菜单时 它显示了三个页面的三个链接。
var menu = [{
title: "Home",
url: "simple-page-a.html"
}, {
title: "My Disputes",
url: "simple-page-b.html"
}, {
title: "Search Disputes",
url: "simple-page-c.html"
}];
// For this "simple demo" we can change event to "pageinit", but for the more advanced features, it has to be bound to "pageshow"
$(document).on("pageshow", function (event) {
var items = '', // menu items list
ul = $(".mainMenu:empty"); // get "every" mainMenu that has not yet been processed
for (var i = 0; i < menu.length; i++) {
items += '<li><a href="' + menu[i].url + '">' + menu[i].title + '</a></li>';
}
ul.append(home);
ul.listview('refresh'); // use cache, as ".mainMenu:empty" will no longer work (append called!)
});
在simple-page-b.html页面中,我有以下代码
<script>
$(document).ready(function() {
methodA();
});
</script>
当我从菜单导航到simple-page-b.html时,就没有调用ready方法,
即使我尝试onload()
,仍然无法正常工作。但是,如果我刷新simple-page-b.html页面,就会调用ready。
如上所示,当我按菜单导航时,如何调用此function(ready)
。