Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 913
Imran Qadir Baksh - Baloch Avatar asked Dec 23 '12 12:12

Imran Qadir Baksh - Baloch


1 Answers

  • 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")
});
like image 137
Gajotres Avatar answered Nov 12 '22 12:11

Gajotres