简体   繁体   English

防止在jquerymobile中应用类

[英]Prevent application of a class in jquerymobile

How can I force ui-btn-active never to be set anywhere? 如何强制ui-btn-active从不设置在任何地方? Listening for events seems very bloaty since I don't really know where it is applied. 监听事件似乎很肿,因为我真的不知道它在哪里应用。

Searching online I only found very outdated solutions. 在线搜索时,我只找到非常过时的解决方案。

You can remove the class in JS on mobileinit 您可以在mobileinit JS中删除该类

$(document).on("mobileinit", function () {
   $.mobile.activeBtnClass = "";
});

Partly an answer.. 部分答案。

You could overwrite the original $.fn.addClass method and remove the className before calling the original addClass: 您可以在调用原始的addClass之前覆盖原始的$.fn.addClass方法并删除className:

var _org = $.fn.addClass;
$.fn.addClass = function(className) {

  className = className.replace(/\bui-btn-active\b/g, '');

  return _org.call(this, className);
}

This will not protect you against: 这将无法保护您免受:

el.className = 'ui-btn-active';
$(el).html('<div class="ui-btn-active"></div>');
el.classList.add('ui-btn-active');
el.innerHTML = '<div class="ui-btn-active"></div>';

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

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