在我之前的问题中,我谈论的是 bootstrap select 插件,其中 destroy 方法正在做一些我不想要的事情。我手动编辑插件,但这不是一个好习惯。
Bootstrap select destroy 从 DOM 中删除原始选择
我想使用自定义方法扩展插件,以便它可以完全按照我的意愿进行操作。
我使用以下方法扩展插件:
$.extend(true, $.fn.selectpicker.prototype, {
customRemove: function () {
this.$newElement.remove();
this.$element.show();
}
});
它位于引导选择脚本文件下的另一个 js 文件中。
我如何称呼这种新方法?我尝试了以下但没有成功:
$('select#begin' + _week + _day).selectpicker("customRemove");
或者
$('select#begin' + _week + _day).selectpicker().customRemove();
我错过了什么吗?
bootstrap select插件中destroy函数的原方法:
remove: function () {
this.$newElement.remove();
this.$element.show();
}