all*_*sef 13 jquery twitter-bootstrap bootbox
我无法捕获bootbox.confirm对话框的show事件,以便在显示之前对对话框进行一些css调整.
我试过以下的事情,但没有成功:
$(document).on("show.bs.modal", function (event) {...});
$(document).on("show", function (event) {...});
$(document).on("show", ".bootbox", function (event) {...});
Run Code Online (Sandbox Code Playgroud)
cod*_*bia 41
这应该适用于您使用Bootbox 4.xx和Bootstrap 3.xx:
var box = bootbox.dialog({
message: '',
title: '',
buttons: {},
show: false
});
box.on("shown.bs.modal", function() {
alert('it worked!');
});
box.modal('show');
Run Code Online (Sandbox Code Playgroud)
或者像这样:
$(document).on("shown.bs.modal", function (event) {...});
Run Code Online (Sandbox Code Playgroud)
我还更喜欢使用全局函数,例如:
function bootbox_confirm(msg, callback_success, callback_cancel) {
var d = bootbox.confirm({message:msg, show:false, callback:function(result) {
if (result)
callback_success();
else if(typeof(callback_cancel) == 'function')
callback_cancel();
}});
d.on("show.bs.modal", function() {
//css afjustment for confirm dialogs
alert("before show");
});
return d;
}
Run Code Online (Sandbox Code Playgroud)
并这样称呼它:
bootbox_confirm("my message", function(){alert('ok')}, function(){alert('cancel')}).modal('show');
Run Code Online (Sandbox Code Playgroud)
或者当没有取消逻辑时:
bootbox_confirm("my message", function(){alert('ok')}).modal('show');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14997 次 |
| 最近记录: |