Explicitly initializing Jquery Mobile?

I am using jquery mobile. I just wanted to stop jquery mobile to do anything unless I explicitly call trigger('create') method. Is there a way to stop jquery mobile auto initialization for some time.

Upvotes: 6

Views: 1882

Answers (1)

Gajotres
Gajotres

Reputation: 57309

  • You can do it by adding this attribute:

    data-enhance="false"
    

to a wanted container.

And you also need to turn this on in the app loading phase:

$(document).one("mobileinit", function () {
    $.mobile.ignoreContentEnabled=true;
});

More about this can be found here:

http://jquerymobile.com/test/docs/pages/page-scripting.html

Example:

http://jsfiddle.net/Gajotres/Xjurd/

You can test it by enabling/disabling $.mobile.ignoreContentEnabled=true;

  • Second option is to do it manually with this line:

    data-role="none"
    

Example:

http://jsfiddle.net/Gajotres/LqDke/

EDIT :

To recreate a page again use this:

$('#index').live('pagebeforeshow', function (event) {
    $.mobile.ignoreContentEnabled = false;
    $(this).attr('data-enhance','true');
    $(this).trigger("pagecreate")
});

Upvotes: 5

Related Questions