问题描述
我不想要 标签的样式.我找到了这样的主题 How to "关闭"jQuery Mobile 的 样式 但我不想将
data-enhance=false
添加到我拥有的每个锚点.我也希望 linkBindingEnabled
能够工作(来自 http://jquerymobile.com/demos/1.2.0/docs/api/globalconfig.html),因为它不会向 标签添加自定义类.
I don't want the styles for the <a>
tag. I've found threads like this How to "turn off" jQuery Mobile's styling of <select> drop downs? but I don't want to be adding data-enhance=false
to every anchor I have. 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.
我可以删除 CSS 文件中的定义,但我更喜欢以编程方式来执行此操作.例如,我注释掉了 .ui-body-c .ui-link
(默认链接),但是我在页脚中的链接仍然得到了增强.而且我确定还有其他小案例,我不想弄得一团糟(虽然有时这是唯一的选择)
I could delete the definitions in the CSS file, but I'd prefer a programmatic way to do it. For example, I comment out .ui-body-c .ui-link
(the default link), but then my links in the footer are still enhanced. 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)
基本上,有没有办法禁用元素选择器"的增强功能?而不是手动添加 data-enhance=false
Basically, is there a way to disable enhancement for a "selector" of elements? Instead of manually adding data-enhance=false
推荐答案
在 jQuery Mobile
中禁用标记增强的方法很少,但在您的情况下只有一种线路解决方案:
There are few ways of disabling markup enhancement in jQuery Mobile
but in your case there's only one single line solution:
$(document).on('pagebeforeshow', '#index', function(){
$('a').removeClass('ui-link');
});
jsFiddle
示例:http://jsfiddle.net/Gajotres/L4KUT/
其他解决方案可以在我的另一个ARTICLE,为了透明,这是我的个人博客.或者在此处找到它.搜索名为:标记增强预防方法的章节.
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";
});
这篇关于jQuery Mobile 禁用某些标签的增强功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!