【问题标题】:Explicitly initializing Jquery Mobile?显式初始化 Jquery Mobile?
【发布时间】:2012-12-10 06:23:30
【问题描述】:

我正在使用 jquery mobile。我只是想阻止 jquery mobile 做任何事情,除非我明确调用 trigger('create') 方法。有没有办法停止jquery mobile自动初始化一段时间。

【问题讨论】:

    标签: javascript jquery html css jquery-mobile


    【解决方案1】:
    • 你可以通过添加这个属性来做到这一点:

      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;

    来测试它
    • 第二个选项是使用这一行手动完成:

      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 来进行初始化。怎么做
    • 看看我的“编辑”部分。在 pagebeforeshow 事件中注释代码以查看它在不重新样式的情况下是如何工作的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-27
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多