我正在使用 Bootstrap Select ( http://silviomoreto.github.io/bootstrap-select/ ) 为我的网站的每个部分显示带有 Font-Awesome 图标的下拉菜单。
我添加了添加新部分的功能 - 单击添加按钮时,会添加一个新部分(与上一部分重复)。在本节中,Bootstrap Select 不起作用。
我试图像这样重新初始化它:
var select = $('[name="section['+ numbersection +'][section_icon]"]');
$(select).selectpicker('destroy');
$(select).selectpicker({
showIcon: false
});
但这不起作用,因为 detroy 方法似乎没有触发。有没有办法在动态添加的元素上重新初始化 Bootstrap Select?