我在我的智慧結束與jQuery Mobile事件。我不明白他們,儘管按照T的文檔。我使用下面的代碼來初始化我的網頁。問題是有些似乎會多次觸發,偶爾當我回到頁面時,什麼也不會出現,就好像.live pageinit根本不會觸發。我很困惑。 pageinit是要走的路嗎?是最好的實踐?我是否需要自己清理並使用諸如頁面隱藏之類的東西來從DOM中刪除內容?請幫助我理解。謝謝!正確使用版本1.7.1中的jQuery Mobile事件處理
// page number 1
<header>
includes and stuff
<header>
<body>
<div data-role="page" data-theme="a" id="dashboardPage">
$('#dashboardPage').live('pageinit',function() {
});
// somewhere in here a page transition to anotherPage.html (not necessarily the id of the new page in the <div data-role-"page data-theme...> declaration
$.mobile.changePage("anotherPage.html",{transition : "slide"});
</div>
</body>
// page number 2
<header>
includes and stuff
<header>
<body>
<div data-role="page" data-theme="a" id="specialsPage">
$('#specialsPage').live('pageinit',function() {
});
</div>
</body>
你如何做一個通用的包含文件?我可以把所有的JavaScript包括在裏面以及我的CSS包括?可能不會,對吧... – Mobie
您可以在首頁的標題中包含CSS和js文件的所有鏈接。從那裏通過jquerymobile瀏覽的任何頁面都將從中受益。 – Romain
這不涉及刷新.. – Mobie