本文介绍了jQuery Mobile禁用增强某些标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想使用< a> 标签的样式。我发现这样的线程,但我不想添加 data-enhancement = false 到每个锚点。我也希望 linkBindingEnabled 将工作(从),因为它不会将自定义类添加到< ; a> 标签。

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-enhancement = 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 示例:

其他解决方案可以在我的其他 ,透明它是我的个人博客。或者 。搜索标记增强预防方法章节。

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禁用增强某些标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 05:54