bootbox.js 库
帮助使用bootstrap框架快速的创建一个对话框,管理或删除任何所需的DOM元素或js事件处理程序,不需要写bootbox代码
api文档
//bootboxjs.com/documentation.html
引入bootbox.js的正确方法
<script src="https://cdn.bootcss.com/bootbox.js/4.4.0/bootbox.min.js"></script>
<script>window.bootbox || document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"><\/script>')
</script>
bootbox.js三方法设计模仿本地JavaScript方法
确切的方法签名是灵活的
每个可以采取各种参数定制标签和指定缺省值
但它们通常被称为一样
bootbox.alert(message, callback)
bootbox.prompt(message, callback)
bootbox.confirm(message, callback)
唯一需要的参数是alert是 message;
callback是必需的 confirm 和 prompt 调用以确定用户的响应
甚至当调用警报回调是确定
当用户 驳回对话框由于我们的包装方法不能不要块
是异步而非同步
这三种方法调用四分之一个公共方法, 可以使用 自己的自定义对话框创建
bootbox.dialog(options)
bootbox基本示例
bootbox.alert("Hello world!", function() {
Example.show("Hello world callback");
});
bootbox.confirm("Are you sure?", function(result) {
Example.show("Confirm result: "+result);
});
bootbox.prompt("What is your name?", function(result) {
if (result === null) {
Example.show("Prompt dismissed");
} else {
Example.show("Hi <b>"+result+"</b>");
}
});
bootbox.dialog({
message: "I am a custom dialog",
title: "Custom title",
buttons: {
success: {
label: "Success!",
className: "btn-success",
callback: function() {
Example.show("great success");
}
},
danger: {
label: "Danger!",
className: "btn-danger",
callback: function() {
Example.show("uh oh, look out!");
}
},
main: {
label: "Click ME!",
className: "btn-primary",
callback: function() {
Example.show("Primary button");
}
}
}
});
bootbox官网 //bootboxjs.com/examples.html
Bootbox 版本 最低Bootstrap 版本 最高Bootstrap 最低jQuery 说明
5.x.x Latest 3.0.0 * 4.x.x 1.9.1 C当前版本。更新以支持Bootstrap4。与Bootstrap 3保持兼容性。
4.x.x 3.0.0 3.4.x 1.9.1 完全重写以支持Bootstrap 3.0.0。
尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题