Home  >  Article  >  Web Front-end  >  A brief analysis of jQuery Mobile's initialization events_jquery

A brief analysis of jQuery Mobile's initialization events_jquery

WBOY
WBOYOriginal
2016-05-16 15:27:411774browse

jQuery Mobile includes an initialization event that loads even before jQuery's document.ready event. jQuery Mobile actually fires its initialization event on the document object itself, and the first event fired is mobileinit.

When Jquery Mobile starts executing, it will trigger the mobileinit event on the document object. Because the mobileinit event is triggered immediately after loading, you need to bind your event handler before Jquery Mobile loads, so I recommend You arrange your js reference order as follows

<script src="Jquery.js"></script>
<script src="您自己的js文件"></script>
<script src="Jquery-mobile.js"></script>

To extend the mobileinit event, you first need to bind it with a custom function. The mobileinit event can be extended using the bind method to override the default configuration (global options).

$(document).bind("mobileinit", function(){
//覆盖的代码
});

Inside the function that binds the event, you can use the $.extend method of the $.mobile object to configure the default parameter values:

$(document).bind("mobileinit", function(){
 $.extend( $.mobile , {
 foo: bar
 });
});

Or set it individually.

$(document).bind("mobileinit", function(){
 $.mobile.foo = bar;
});

The $.mobile object is the starting point for setting all properties

<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>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn