Home > Web Front-end > JS Tutorial > body text

A brief analysis of jQuery Mobile's initialization events_jquery

WBOY
Release: 2016-05-16 15:27:41
Original
1802 people have browsed it

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>
Copy after login

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(){
//覆盖的代码
});
Copy after login

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
 });
});
Copy after login

Or set it individually.

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

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>
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template