我有一个模态,身体充满了Ajax响应。
JavaScript代码:
$('body').on('click','.modal-show', function(event){
event.preventDefault();
var me = $(this),
url = me.attr('href'),
title = me.attr('title');
$('#modal-title').text(title);
$('#modal-btn-save').text(me.hasClass('btn-edit') ? 'Update' : 'Tambah').removeClass('d-none');
$.ajax({
url: url,
dataType: "html",
success: function (response) {
$('#modal-body').html(response);
$('.selectpicker').selectpicker();
}
});
$('#modal-center').modal('show');
});
URL Ajax引用此代码:
<form action="{{ route('sub.store') }}" method="POST">
<div class="form-group">
<label for="id_kategori" class="control-label">kategori</label>
<select name="id_kategori" class="selectpicker" data-size="5" data-actions-box="true">
<optgroup label="kategori">
<!-- get sekolah -->
@foreach($kategori as $kg)
<option value="<?= $kg["id_kategori"]; ?>"><?= $kg["kategori"]; ?></option>
@endforeach
</optgroup>
</select>
</div>
为什么引导选择不起作用?即使没有模式,引导选择仍然有效吗?