HTML
<a href="#modal-2" role="button" class="btn" data-toggle="modal">Modal with animation</a>
<div id="modal-2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary" id="book" >Save changes</button>
</div>
</div>
我使用了floowing JS,但没有结果
$('#book').click(function(e) {
$.ajax({
url: base_url+"admin/login/",
type: "get",
data: {Name:name, Mobile:mobile},
success: function( strData ){
//$('.modal, .modal-backdrop').hide();
$("#modal-2").modal('hide');
},
error: function(){
$('#report').text('Sorry, Please try again').css('color', 'red');
}
});
});
这里我想在单击“保存”按钮后在回调中调用ajax函数。 然后在ajax成功之后我想关闭bootbox弹出窗口
答案 0 :(得分:1)
如果你使用BootBox,你可以这样做:
bootbox.dialog({
message: "Your Message Here - You can pass in an HTML string",
title: "Your Title",
onEscape: function () {
bootbox.hideAll();
},
buttons: {
danger: {
label: "Cancel",
className: "btn default",
callback: function () {
bootbox.hideAll();
}
},
success: {
label: "Add",
className: "btn blue",
callback: function () {
//Add functionality here
// Then close the model using
bootbox.hideAll();
}
}
}
});
答案 1 :(得分:0)
在ajax定义中你应该使用参数
async : false
您可能需要在模态窗口的主体内使用自定义按钮,而不是来自bootbox