问题描述
我目前正在其中一个项目中使用插件。
我有一个动态生成的表,其中包含select元素,然后我使用以下命令将其转换为bootstrap select:
I am currently using the Bootstrap select plugin in one of my projects.I have a dynamically generated table that has select elements which I then convert to bootstrap select using the command:
_tr.find('select.selectpicker').selectpicker({ size: 10 });
其中 _tr
是我添加的行选择元素。这工作正常,引导选择显示在firebug中我仍然看到原始的select元素。
Where _tr
is the row where I added the select elements. This is working fine, the bootstrap select is shown and in firebug I still see the original select element.
现在每一行都有一个按钮,它删除(销毁)引导程序选择。
但是它也删除了原来的选择,那就是问题,因为我仍然需要原来的选择来做其他事情。
Now every row has a button where it removes ( destroy ) the bootstrap select.But it removes also the original select, and thats the poblem because I still need the original select to do something else.
我使用以下命令来销毁:
I use the following command to destroy:
$('select#begin' + _week + _day).selectpicker("destroy");
$('select#end' + _week + _day).selectpicker("destroy");
$('select#pause' + _week + _day).selectpicker("destroy");
在其他插件中如果使用destroy,它会再次显示原始元素。这是boostrap select插件中的一个问题,还是有另一种方法可以删除bootstrap select并重新显示原始选择。
In other plugins if you use destroy, it shows the original element again. Is this an issue in the boostrap select plugin or is there another way to remove the bootstrap select and reshow the original select.
推荐答案
找到解决方案,我编辑插件函数destroy而不是删除原始元素,我把它显示回来:
Found the solution, I edit the plugin function destroy where instead of removing the original element, I show it back:
remove: function () {
this.$newElement.remove();
this.$element.show(); // First it was this.$element.remove();
}
这篇关于Bootstrap select destroy从DOM中删除原始选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!