这是我的尝试:
$('#modalSetComplain').on('show.bs.modal', function (e) {
FillinputComplaintype2();
});
这是将动态填充
的功能 function FillinputComplaintype2() {
var options = $("#inputComplaintype2");
$.each( datelist , function (val, text) {
options.append($("<option />").val(text.Name).text(text.Id));
});
}
这是我的模态
<div class="modal modal-flex " id="modalSetComplain">
<div class="modal-dialog" style="min-width: 900px; max-width:1000px;width:auto">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"></span></button>
<h4 class="modal-title"> </h4>
</div>
<div class="modal-body">
<div class="form-horizontal" >
<div class="form-group">
<label class="col-sm-2 control-label" for="inptComplaintitle" style="width:15%"><strong> </strong></label>
<input type="text" name="inptComplaintitle" class="form-control" id="inptComplaintitle" style="width:60%"/>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="inputComplaintype2" style="width:15%"><strong> </strong></label>
<select class="form-control" id="inputComplaintype2" style="width:60%"></select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"></button>
<button type="button" onclick="SaveComplains();" class="btn btn-green ladda-button">
</button>
</div>
</div>
</div>
</div>
我的模态已成功出现,但如何填写id="inputComplaintype2"
模态加载的日常情况?
还
$('#modalSetComplain').on('show.bs.modal', function (e) {
即使它位于document.ready
,也没有触发其活动答案 0 :(得分:0)
我认为你应该使用shown
事件(模态出现后)而不是show
事件。
$('#modalSetComplain').on('shown.bs.modal', function (e) {
FillinputComplaintype2();
});