關於JQueryMobile的Error Loading Page問題的解決
默認情況JQUERY MOBILE會捕獲對鏈接點擊的事件,試圖通過AJAX的方式載入目標頁面。但如果目標頁面是302重定向的方式,則會彈出Error Loading Page的錯誤。
折騰了很久,也嘗試通過
$(document).bind("mobileinit", function(){
$.mobile.ajaxEnabled=false;
});
來禁止之,但一直無效。
最後找到一段話:
To disable pages loading through Ajax bind 'mobileinit' and override $.mobile.ajaxEnabled (You need to bind 'mobileinit' before referencing the jQuery mobile script) or add data-ajax="false" or rel="external" to
the link element.
添加了之後一切OK。
<a href="gonggao.html" rel="external"> 公告</a> 從首頁home.html連接到gonggao.html
參考:
http://jquery-ui-map.googlecode.com/svn/trunk/demos/jquery-mobile-example.html