显式初始化Jquery Mobile?

6

我正在使用jQuery Mobile。我只想在显式调用trigger('create')方法之前停止jQuery Mobile执行任何操作。有没有一种方法可以暂时停止jQuery Mobile的自动初始化。

1个回答

5
  • You can do it by adding this attribute:

    data-enhance="false"
    

将其放入所需的容器中。

在应用程序加载阶段,您还需要打开此选项:

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

更多相关信息可以在这里找到:

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

示例:

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

您可以通过启用/禁用$.mobile.ignoreContentEnabled=true;来测试它。
  • Second option is to do it manually with this line:

    data-role="none"
    

例子:

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

编辑 :

若要重新创建一个页面,请使用以下方法:

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

现在,我需要显式地调用jQuery Mobile来进行初始化。如何做到这一点? - Imran Qadir Baksh - Baloch
请看我的“EDIT”部分。在pagebeforeshow事件中注释掉一段代码,以查看它在不重新排版的情况下如何工作。 - Gajotres

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接