我对 bootstrap add-on select picker有疑问。我是通过JS动态添加它们的,添加后它们不会被激活。它们就在那里,您可以单击它们,但不能选择该选项。这是简化的代码(或者这里是LIVE DEMO)。
<script>
$(function () {
$("#add").click(function () {
$(".pattern").clone().removeClass("hidden pattern").addClass("col-md-24 added").prependTo("#next-line");
});
$(".remove").click(function () {
console.log("remove");
$(this).parent('.added').remove();
});
$('.selectpicker').selectpicker();
});
</script>
<!-- .... -->
<button type="button" id="add" class="btn btn-success"><span class="fa fa-plus"></span></button>
<form method="POST">
<select class="selectpicker" name="id[]" data-live-search="true">
<!-- .... -->
</select>
<div id="next-line">
</div>
<button type="submit" name="save" class="btn btn-lg btn-success"><span class="fa fa-lg fa-send"></span> Send</button>
</form>
<div class="pattern hidden">
<select class="selectpicker" name="id[]" data-live-search="true">
<!-- .... -->
</select>
</div>
谢谢你的帮助。