jQuery Mobile 包括一個初始化事件,該事件甚至會先于 jQuery 的 document.ready 事件進行加載。jQuery Mobile 實際上在文檔對象本身上觸發其初始化事件,第一個觸發的事件是mobileinit。
當Jquery Mobile開始執行時,他就會在document對象上觸發mobileinit 事件,因為mobileinit事件是在加載后馬上觸發,所以你需要在Jquery Mobile加載之前綁定你的事件處理函數,所以我建議你如下安排你的js引用順序
<script src="Jquery.js"></script><script src="您自己的js文件"></script><script src="Jquery-mobile.js"></script>
要擴展 mobileinit 事件,您首先需要將它與一個自定義函數進行綁定。可使用 bind 方法擴展 mobileinit 事件,來覆蓋默認配置(全局選項)。
$(document).bind("mobileinit", function(){//覆蓋的代碼});
在綁定事件的函數內部,你可以使用$.mobile對象的$.extend方法來配置默認參數值:
$(document).bind("mobileinit", function(){ $.extend( $.mobile , { foo: bar });});
或者單獨設置它。
$(document).bind("mobileinit", function(){ $.mobile.foo = bar;});
$.mobile 對象是設置所有屬性的起始點
<script type="text/java script" src="/scripts/jquery-1.6.min.js"></script><script type="text/java script">$(document).bind("mobileinit", function(){$.mobile.defaultTransition = "slidedown";$.mobile.ajaxLinksEnabled = false; // 禁用Ajax提交$.mobile.ajaxFormsEnabled = false; // 禁用Ajax提交$.mobile.ajaxEnabled = false; //禁用Ajax提交});</script><script type="text/java script" src="/scripts/mobile/jquery.mobile-1.0b1.min.js"></script>