我正在尝试使用Bootbox创建一个模态.我有模态弹出窗口,并要求您填写一些数据.然后我尝试进行验证,所以当他们点击保存时,它会检查以确保填写字段.
如果验证失败,如何在单击"保存"时阻止模式关闭?
bootbox.dialog(header + content, [{
"label": "Save",
"class": "btn-primary",
"callback": function() {
title = $("#title").val();
description = $("#description").val();
icon = $("#icon").val();
href = $("#link").val();
newWindow = $("#newWindow").val();
type = $("#type").val();
group = $("#group").val();
if (!title){ $("#titleDiv").attr('class', 'control-group error'); } else {
addMenu(title, description, icon, href, newWindow, type, group);
}
}
}, {
"label": "Cancel",
"class": "btn",
"callback": function() {}
}]);
Run Code Online (Sandbox Code Playgroud) 我似乎无法自动将焦点集中在Bootbox的文本字段上.
这是我的代码:function setCode(myCode){
bootbox.confirm("Enter your PIN: <input id='pin_code' type='password' name='pin_code'></input>",
function(result) {
if(result)
console.log($("#pin_code").val());
});
$("#pin_code").focus();
};
Run Code Online (Sandbox Code Playgroud)
关于bootbox的代码可能会受到影响吗?
我正在使用bootbox创建一个对话框.
bootbox.dialog({
message: 'Datepicker input: <input id="date"></input>',
title: "Custom label",
buttons: {
main: {
label: "Save",
className: "btn-primary",
callback: function () {
console.log("Hi " + $('#first_name').val());
}
}
}
});
$("#date").datepicker(); //Not working
Run Code Online (Sandbox Code Playgroud)
有关如何使用datepicker输入创建启动箱提示的任何想法?谢谢
在我目前的项目中,我使用bootbox来替换旧的普通警报,并确认盒子是时髦的.但问题是在关闭或解除bootbox之后它的焦点不会返回到我的输入.
bootbox.alert("Please create a milestone");
$('input[name="mile_stone[]"]:first').focus();
return false;
Run Code Online (Sandbox Code Playgroud)
除焦点功能外,一切都按预期工作.有什么方法可以解决这个问题吗?
bootbox当用户通过“x”按钮关闭对话框时,是否有调用函数的选项?使用bootbox.dialog().
有没有这样的:
bootbox.dialog({
message : 'My message',
callback : function() {
// User is closin' the dialog. Come on do somethin'
}
});
Run Code Online (Sandbox Code Playgroud)
我什至尝试过close,closing而closeCallback不是callback,但他们都没有工作。
我想知道是否有办法以dinamically方式更新bootbox模式的内容.
例
bootbox.dialog({
message: "Hi there",
title: "My title",
buttons: {
main: {
label: "dismiss",
className: "btn-primary",
}
}
});
newMessage = "this is a new message"
Run Code Online (Sandbox Code Playgroud)
有没有办法用新字符串newMessage替换"你好"?
感谢您的任何帮助或建议
我想用bootbox显示textarea元素.此textarea应与WYSIWYG编辑器一起使用,该编辑器将由初始化
$('#editor').redactor();
Run Code Online (Sandbox Code Playgroud)
所以我想在显示textarea的那一刻添加它.我试过这个:
bootbox.dialog({
title: "Title",
message: '<textarea id="editor"></textarea>',
init: function () {
$('#editor').redactor();
}
});
Run Code Online (Sandbox Code Playgroud)
但这似乎是错误的.
我正在使用bootbox图书馆。我有一个按钮叫做Delete。
$('body').on("click", ".deleteDiagnostic", function () {
var id = $(this).attr("data-diagnosticID");
var currentRow = $(this).closest('tr');
bootbox.confirm("Are you sure want to delete?", function (result) {
if (result == true) {
//code here
}
});
});
Run Code Online (Sandbox Code Playgroud)
我也在使用PartialView,并且包含按钮的页面是动态加载的。有时当我点击时,bootbox 会打开多次,我不知道为什么。
PS:当我PartialView第一次加载时它运行良好,但是当我加载PartialView多次时,点击时会bootbox出现多次button。
当我在页面上使用JQuery Select2时它工作正常.但是,当它位于引导框对话框模式中时,它无法正确显示.
这是我正在使用的jquery代码...
$.ajax({
type: 'GET',
url: src,
success: function (data) {
if (allowed) {
bootbox.dialog({
title: dialogTitle,
message: $('#altForm'),
onEscape: true,
show: false // We will show it manually later
}).on('shown.bs.modal', function () {
$('#enterBtn').hide();
$('#userPwd').hide();
$('.app-ctrl').prop('disabled', true);
$('#altForm').show();
}).on('hide.bs.modal', function (e) {
$('#altForm').hide().appendTo('body');
}).modal('show');
$('.boop').parents('.bootbox').removeAttr('tabindex');
$('.boop').select2();
}
}
});
Run Code Online (Sandbox Code Playgroud)
我相信Select2下拉列表的代码是有效的,因为当我注释掉初始化行时:$('.boop').select2(); 选择下拉列表变为常规下拉列表.但我不知道为什么它显示不正确.
谁能告诉我应该如何将 Bootbox的ok&cancel选项更改为yes& no。
function deletelaw(id) {
bootbox.confirm('Are you sure you want to delete?', function(result) {
if (result) {
$("#deletelaw_" + id).hide();
$(".law1_" + id).prop("checked", false);
var splits = $("#laws_assigned1").val().split(",");
var finalSplit = [];
for (var i = 0; i < splits.length; i++) {
if (id != splits[i]) {
finalSplit.push(splits[i]);
}
}
$("#laws_assigned1").val(finalSplit.join());
}
});
}
Run Code Online (Sandbox Code Playgroud) bootbox ×10
javascript ×6
jquery ×4
asp.net-mvc ×1
datepicker ×1
focus ×1
html ×1
laravel ×1
redactor ×1
select2 ×1