Twitter bootstrap 单击“选项”时,Select2 on bootstrap模式消失?
为什么单击选项结果时select2消失?它使用ajax源数据,当单击搜索结果时,选择选项将消失Twitter bootstrap 单击“选项”时,Select2 on bootstrap模式消失?,twitter-bootstrap,modal-dialog,jquery-select2,Twitter Bootstrap,Modal Dialog,Jquery Select2,为什么单击选项结果时select2消失?它使用ajax源数据,当单击搜索结果时,选择选项将消失 选择2版本:4.0.5 jQuery版本:jQuery v1.11.1 我使用codeigniter,以下是我的代码: 观点 我今天也有同样的问题,在得到解决方案后,我只看到你最后的反馈,这些反馈是你自己解决的。我的解决方案是使用add.not()选择器将select2元素从函数效果中排除 我正在使用 选择2版本4.0.11 jQuery版本3.4.1 引导版本4.3.1 以前 $("sele
- 选择2版本:4.0.5
- jQuery版本:jQuery v1.11.1
我今天也有同样的问题,在得到解决方案后,我只看到你最后的反馈,这些反馈是你自己解决的。我的解决方案是使用add.not()选择器将select2元素从函数效果中排除 我正在使用
- 选择2版本4.0.11
- jQuery版本3.4.1
- 引导版本4.3.1
$("select").change(function(){
$(this).parent().parent().removeClass('has-error');
$(this).next().empty();
});
之后
希望能帮助其他人寻找类似问题的解决方案。我试图重现您的问题,但没有发现任何问题。看看我的小提琴:知道怎么了吗?我使用firefox浏览器,这与浏览器问题有关吗?我的小提琴在firefox 57上也能正常工作。。。也许您可以共享更多代码,以了解是否存在错误。你检查过我的小提琴吗?是的,我检查过你的小提琴。我在我的js
$(“select”).change(function(){$(this.parent().parent().removeClass('has-error');$(this.next().empty();)上发现了一个错误,因为这个代码代码>问题已解决
$('.select_tindakan_id').select2({
placeholder: '--- Silahkan Pilih ---',
dropdownParent: $("#modal_form"),
width: '100%',
ajax: {
url: '<?php echo site_url('perawatan/layanan_tindakan_pasien_/search_tindakan'); ?>',
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: data
};
},
cache: true
},
minimumInputLength: 2
});
public function search_tindakan()
{
$json = [];
$this->load->database();
if(!empty($this->input->get("q"))){
$this->db->like('nama', $this->input->get("q"));
$query = $this->db->select('id,nama as text,tindakan_id')
->limit(10)
->get("tindakan_item");
$json = $query->result();
}
echo json_encode($json);
}
$("select").change(function(){
$(this).parent().parent().removeClass('has-error');
$(this).next().empty();
});
$("select").not('.select2').change(function(){
$(this).parent().parent().removeClass('has-error');
$(this).next().empty();
});