bootstraptable 删除之后下拉框无法即时再次加载

1 $.get('del', {ids : selections}, function(data) {
2     bootbox.alert('执行成功!');
3     $table.bootstrapTable('refresh');
4     $("#updeptId").empty();
5 });

需要在删除之后先执行empty();清空下拉框的方法,之后重新发送请求,请求下拉框中的值

 1 <div class="col-xs-6">
 2     <label for="updeptId" class="control-label">上级部门:</label>
 3     <select class="form-control select2" id="updeptId" name="updeptId" style=" 100%">
 4     </select>
 5     <label class="error" for="updeptId"></label>
 6 </div>
 7 <script>
 8 var select2FormValue = {};
 9 select2FormValue.updeptId='';
10 $("#modalForm").on("shown.bs.modal", function() {
11     initDept();
12 });
13 
14 $("#btnadd").click(function() {
15     select2FormValue.updeptId="";
16     $('#modalForm').modal('show');
17 });
18 function initDept() {
19 $.getJSON("${pageContext.request.contextPath}/select", {},function(data) {
20     select2Data = data.items;
21     $("#updeptId").select2({
22         data : select2Data,
23     dropdownParent : $('#modalForm'),
24     placeholder:'请选择'
25     });
26     $("#updeptId").val(select2FormValue.updeptId).trigger('change');
27 });
28 } 
29 </script>   

 

原文地址:https://www.cnblogs.com/aiyowei/p/8443950.html