An analysis of initialization events of jquery mobile _jquery

Source: Internet
Author: User
Tags commit extend

The jquery Mobile includes an initialization event that can even be loaded before the Document.ready event in jquery. JQuery Mobile actually triggers its initialization event on the document object itself, and the first event that is triggered is mobileinit.

When jquery mobile begins to execute, he triggers the Mobileinit event on the Document object because the Mobileinit event is triggered immediately after loading, so you need to bind your event handler before the jquery mobile load. So I suggest that you arrange your JS reference order as follows

<script src= "Jquery.js" ></script>
<script src= "Your own JS file" ></script>
<script src = "Jquery-mobile.js" ></script>

To extend the Mobileinit event, you first need to bind it to a custom function. You can use the Bind method to extend the Mobileinit event to override the default configuration (Global option).

$ (document). Bind ("Mobileinit", function () {
//Overwrite Code
});

Within 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; Disable Ajax commit
$.mobile.ajaxformsenabled = false;//disable Ajax commit
$.mobile.ajaxenabled = false;//disable AJAX submission
} c12/></script>
<script type= "Text/java script" src= "/scripts/mobile/jquery.mobile-1.0b1.min.js" > </script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.