如何在Bootstrap的Bootbox中有两个输入而不是一个输入?
我需要在模态对话框中接收2个值.
我正在使用bootbox来显示对话框.
如果我使用bootbox.confirm,bootbox.alert或者bootbox.prompt,当按下escape键或在对话框外单击时,对话框将按预期关闭
但是在使用时bootbox.dialog,当我点击对话框外面或escape按键时,对话框没有关闭,如何让它像其他对话框一样工作?
var box = bootbox.dialog({
show: false,
backdrop: true,
animate: false,
title: 'Bla',
message: 'bla bla bla',
buttons: {
cancel: {
label: 'Cancel',
className: 'btn-warning'
},
save: {
label: 'Parse',
className: 'btn-success',
callback: function () {
// handling with ajax
return false;
}
}
}
});
box.modal('show');
Run Code Online (Sandbox Code Playgroud) 在Bootbox 3.2.0中,我能够使用确认字符串传递如下:
bootbox.confirm(
confirm_string,
cancel_string,
yes_string,
function(r) {
if (r) {
//do something
}
}
);
Run Code Online (Sandbox Code Playgroud)
我升级到4.1.0,上面的函数调用出错了.
根据Bootbox 4.1.0 的文档(http://bootboxjs.com/documentation.html),有两种方法可以调用confirm:
bootbox.confirm(str message, fn callback)
bootbox.confirm(object options)
Run Code Online (Sandbox Code Playgroud)
我用消息字符串和回调函数测试了第一种方式并且它有效.对于第二种方式,我能够传递一个对象,如下所示:
{
message: message_string
callback: function(r) {
//do something
}
}
Run Code Online (Sandbox Code Playgroud)
如何以第二种方式为OK,Cancel按钮传递字符串?
感谢致敬.
我正在加载一个对话框,其中包含使用Bootbox.js即时构建的表单,我正在使用jQuery validate插件验证用户输入.
验证工作正常,但submitHandler在成功填写表单时会被忽略.
出了什么问题?
submitHandler: function(form) {
alert("Submitted!");
var $form = $(form);
$form.submit();
}
Run Code Online (Sandbox Code Playgroud)
请参阅下面的完整示例.我查看了其他提出类似问题的帖子.不幸的是,他们似乎在页面上呈现了表单,而我正在通过jQuery渲染.
$(document).on("click", "[data-toggle=\"contactAdmin\"]", function() {
bootbox.dialog({
title: "Contact admin",
buttons: {
close: {
label: 'Close',
className: "btn btn-sm btn-danger",
callback: function() {}
},
success: {
label: "Submit",
className: "btn btn-sm btn-primary",
callback: function() {
$("#webteamContactForm").validate({
rules: {
requestType: {
required: true
}
},
messages: {
requestType: {
required: "Please specify what your request is for",
}
},
highlight: function(a) { …Run Code Online (Sandbox Code Playgroud)不幸的是,文档Bootbox(http://paynedigital.com/2011/11/bootbox-js-alert-confirm-dialogs-for-twitter-bootstrap)没有教授如何调用确认对话框.由于在加载页面时始终显示文档窗口,因此在单击删除按钮调用时应出现错误.这是尝试失败的代码.
// show "false" does not work, the confirm window is showing when page is loaded.
$(function () {
bootbox.confirm("Confirm delete?", "No", "Yes", function(result) {
show: false
});
});
// need show the confirm window when the user click in a button, how to call the confirm window?
<td><a class="icon-trash" onclick="bootbox.confirm();" href="{% url 'del_setor' setor.id %}" title="Delete"></a></td>
Run Code Online (Sandbox Code Playgroud)
如何仅在单击删除按钮时才设置此引导框?谢谢!
编辑 - 解决方案:
$(function () {
$("a#confirm").click(function(e) {
e.preventDefault();
var location = $(this).attr('href');
bootbox.confirm("Confirm exclusion?", "No", "Yes", function(confirmed) {
if(confirmed) …Run Code Online (Sandbox Code Playgroud) 我无法捕获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) 我正在使用Bootstrap作为Web应用程序,并使用bootbox(http://bootboxjs.com)显示一个窗口,然后再继续执行删除操作.
对于不同的删除选项,我需要显示不同的消息.我想显示不同宽度的确认窗口.
如何在javascript代码中动态执行此操作?我看了一切,无法找到解决方案.
感谢您的任何想法和建议!
干杯.
我试图自定义bootboxjs.prompt选项,但它似乎不允许选项对象作为参数
这是来自http://bootboxjs.com/index.html#api的示例
bootbox.prompt("What is your name?", function(result) {
if (result === null) {
Example.show("Prompt dismissed");
} else {
Example.show("Hi <b>"+result+"</b>");
}
});
Run Code Online (Sandbox Code Playgroud)
这就是我想要传递的内容:
var promptOptions = {
title: "Custom label",
buttons: {
confirm: {
label: "Save"
}
}
};
bootbox.prompt(promptOptions, function(result) {
if (result === null) {
console.log("Prompt dismissed");
} else {
console.log("Hi "+result);
}
});
Run Code Online (Sandbox Code Playgroud)
如何自定义标题和按钮标签?
是否可以在10秒后关闭Twitter启动箱?!我这样打开它:
bootbox.confirm("{{$steps[0]}}","accept","decline" ,function(result) {
if (result) {
}
});
Run Code Online (Sandbox Code Playgroud)