简体   繁体   English

jQuery Mobile禁用某些标签的增强功能?

[英]jQuery Mobile disable enhancement on certain tags?

I don't want the styles for the <a> tag. 我不想要<a>标签的样式。 I've found threads like this How to "turn off" jQuery Mobile's styling of <select> drop downs? 我发现这样的线程如何“关闭”jQuery Mobile的<select>下拉样式? but I don't want to be adding data-enhance=false to every anchor I have. 但我不想将data-enhance=false添加到我拥有的每个锚点。 I was also hoping linkBindingEnabled would work (from http://jquerymobile.com/demos/1.2.0/docs/api/globalconfig.html ), as in it wouldn't add custom classes to the <a> tag. 我也希望linkBindingEnabled可以工作(来自http://jquerymobile.com/demos/1.2.0/docs/api/globalconfig.html ),因为它不会向<a>标签添加自定义类。

I could delete the definitions in the CSS file, but I'd prefer a programmatic way to do it. 我可以删除CSS文件中的定义,但我更喜欢以编程方式来完成它。 For example, I comment out .ui-body-c .ui-link (the default link), but then my links in the footer are still enhanced. 例如,我注释掉.ui-body-c .ui-link (默认链接),但是页脚中的链接仍然是增强的。 And I'm sure there are other little cases, and I don't want to make it messy (although sometimes that's the only option) 我确信还有其他一些小案例,而且我不想让它变得混乱(尽管有时这是唯一的选择)

Basically, is there a way to disable enhancement for a "selector" of elements? 基本上,有没有办法禁用元素“选择器”的增强? Instead of manually adding data-enhance=false 而不是手动添加data-enhance=false

There are few ways of disabling markup enhancement in jQuery Mobile but in your case there's only one single line solution: jQuery Mobile中禁用标记增强的方法很少,但在您的情况下,只有一个单行解决方案:

$(document).on('pagebeforeshow', '#index', function(){       
   $('a').removeClass('ui-link');
});

jsFiddle example: http://jsfiddle.net/Gajotres/L4KUT/ jsFiddle示例: http//jsfiddle.net/Gajotres/L4KUT/

Other solutions can be found in my other ARTICLE , to be transparent it is my personal blog. 其他解决方案可以在我的其他文章中找到,透明它是我的个人博客。 Or find it HERE . 或者在这里找到它。 Search for the chapter called: Methods of markup enhancement prevention . 搜索名为: 标记增强预防方法的章节。

There you will find a answer how to disable it on a selector level, unfortunately it only works on native form elements and a tag is not a native form element: 在那里你会找到一个如何在选择器级别禁用它的答案,不幸的是它只适用于本机表单元素,而标签不是本机表单元素:

$(document).bind('mobileinit',function(){
     $.mobile.page.prototype.options.keepNative = "select, input";
});  

To disable enhancement of a select component you can add data-role='none' , tested on jQuery Mobile 1.4.2. 要禁用select组件的增强,可以在jQuery Mobile 1.4.2上添加data-role='none'

see http://jsfiddle.net/zLZzA/1/ http://jsfiddle.net/zLZzA/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM