【问题标题】:How can i stop jQuery mobile to apply styles to my specific form elements如何停止 jQuery mobile 将样式应用于我的特定表单元素
【发布时间】:2012-04-23 21:55:56
【问题描述】:

是否可以指示 jQuery Mobile 不设置我的输入框和提交按钮的样式。我对我的自定义 CSS 很满意。 jQuery 移动脚本正在将自己的样式应用于我的所有元素。

我尝试的一种解决方法是在我的自定义 css 中覆盖这些元素。有没有其他可用的功能我可以做到这一点?像这样的东西

$.ignoreStyles("button,text");

【问题讨论】:

    标签: css jquery-mobile


    【解决方案1】:

    jQuery Mobile 将忽略 data-role 属性设置为 none 的元素。因此,您可以简单地将这些属性添加到您的标记中:

    <input type="text" name="foo" data-role="none" />
    <button type="button" id="bar" data-role="none">Button</button>
    

    【讨论】:

    • 非常适合那些需要避免在某些页面和某些元素上使用 jquery 移动样式的例外情况。
    • data-role="none" 的提交按钮还能正常工作吗?
    【解决方案2】:

    这对我有用。

    $(document).bind("mobileinit", function() {
      $.mobile.ignoreContentEnabled = true;
    });
    
    <div data-enhance="false">
        <input type="checkbox" name="chkbox1" id="chkbox1" 
          checked />
        <label for="chkbox1">Checkbox</label>
        <input type="radio" name="radiobtn1" id="radiobtn1" 
          checked />
        <label for="radiobtn1">Radio Button</label>
      </div>
    

    【讨论】:

      【解决方案3】:

      @angelokh 解决方案对我有用。另请查看以下链接:

      http://my.safaribooksonline.com/book/-/9781849517225/7dot-configurations/ch07s06_html

      另外关键是在包含 jquery.mobile.js 之前添加以下脚本:

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

      【讨论】:

      • 给定的链接有解决方案,但你在这里的答案并不完整......无论如何,thanx
      • 那么使用jquery mobile的目的是什么?
      【解决方案4】:

      试试这个

      $(document).on('pagebeforecreate', function( e ) {
          $.mobile.ignoreContentEnabled=true;
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-22
        • 2012-01-29
        • 2011-11-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多