我在我的Modal上创建了一个dropdownchecklist,我用ajax将数据发送到模态
这是我的模态视图
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><img src="<?php echo url().'/assets/buzzohero/front/img/close.png' ?>"></button>
<h4 class="modal-title">Edit {{ $campaign->campaign_name }}<span></span></h4>
</div>
<div class="modal-body">
<input type="hidden" name="campaign_id" value="{{ $campaign->id }}">
<span>Choose the campaign's category</span>
<select class="form-control" name="category[]" multiple="multiple" id="dropdown">
<?php $parents = ""; ?>
@foreach($categories as $result)
<optgroup label="{{$result->name_category}}">
@if(!empty($result->child))
@foreach($result->child as $value)
<option value="{{$value->id}}">{{$value->name_category}}</option>
@endforeach
@endif
</optgroup>
<?php $parents .= $result->id.","; ?>
@endforeach
</select>
<input value="{{$parents}}">
</div>
<link rel="stylesheet" type="text/css" href="{{ asset('assets/dropdownchecklist/smoothness-1.8.13/jquery-ui-1.8.13.custom.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('assets/dropdownchecklist/ui.dropdownchecklist.themeroller.css') }}">
<script type="text/javascript" src="{{ asset('assets/dropdownchecklist/jquery-1.6.1.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('assets/dropdownchecklist/jquery-ui-1.8.13.custom.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('assets/dropdownchecklist/src/ui.dropdownchecklist.js') }}"></script>
<script>
$(document).ready(function() {
$("#dropdown").dropdownchecklist({ icon: {}, width: 400, maxDropHeight: 550 });
});
</script>
我用ajax发送的数据,我可以很好地收到它,但问题是dropdownchecklist有时会出现,有时候点击它时不会显示数据..会发生什么?
我正在尝试不同的东西,我尝试在mozilla打开检查元素并让检查窗口打开。我刷新页面并尝试dropdownchecklist,它始终显示并运行良好。会发生什么?
答案 0 :(得分:0)
我在我的视图脚本中添加了set time out,用于javascript加载脚本
setTimeout(function() {
$.ajax({
url: "{{ URL::to('admin/campaign/edit') }}"+ '/' + id,
type: "GET"
}).done(function(results){
console.log(results);
$("#edit-campaign-body").html(results);
});
}, 100);
它的工作就像一个魅力。