Bootbox 4.1.0:如何将本地化字符串(如 Ok、Cancel)传递给 Bootbox 的确认
Bootbox 4.1.0: how to pass localized strings such as Ok, Cancel to Bootbox's confirm?
在 Bootbox 3.2.0 中,我能够使用如下所示的字符串进行确认:
bootbox.confirm(
confirm_string,
cancel_string,
yes_string,
function(r) {
if (r) {
//do something
}
}
);
我正在升级到 4.1.0,但上述函数调用出现错误。
根据 Bootbox 4.1.0 的文档 (http://bootboxjs.com/documentation.html),有两种方法可以调用 confirm:
bootbox.confirm(str message, fn callback)
bootbox.confirm(object options)
我用消息字符串和回调函数测试了第一条方式,它可以工作。对于第二种方式,我能够按如下方式传递一个对象:
{
message: message_string
callback: function(r) {
//do something
}
}
如何以第二种方式传递"确定"、"取消"按钮的字符串?
谢谢和问候。
作为替代方案,这也可以直接使用 bootbox.confirm
来完成,如下所示:
bootbox.confirm({
buttons: {
confirm: {
label: 'Localized confirm text',
className: 'confirm-button-class'
},
cancel: {
label: 'Localized cancel text',
className: 'cancel-button-class'
}
},
message: 'Your message',
callback: function(result) {
console.log(result);
},
title: "You can also add a title",
});
或使用本地化 - 选项,以更改每个默认值的所有按钮:
bootbox.setDefaults({
/**
* @optional String
* @default: en
* which locale settings to use to translate the three
* standard button labels: OK, CONFIRM, CANCEL
*/
locale: "de"
});
看到: http://bootboxjs.com/documentation.html, "帮助程序方法"
您可以使用"自定义对话框"(bootbox.dialog
)来更改这些字符串。
bootbox.dialog({
message: "Custom message",
title: "Custom title",
buttons: {
danger: {
label: "Custom Cancel",
className: "btn-danger",
callback: function() {
//do something
}
},
main: {
label: "Custom OK",
className: "btn-primary",
callback: function() {
//do something else
}
}
}
});
相关文章:
- 获取Meteor中自定义Bootbox字段的值
- javascript confirm()ok和cancel返回相同的结果
- 是否可以将alertify.js的cancel按钮和onclose调用的操作分开
- 使用ajax和bootbox进行非法调用
- bootbox 4.4如何使用不同的按钮标签进行提醒
- Bootbox:取消对话框后的回调功能/点击'X'按钮
- 在带有 bootbox 的自定义对话框中添加选项以选择表单控件.js在 ASP.NET MVC 中
- 引导程序弹出窗口(bootbox)中的Javascript事件不起作用
- Bootbox,两个模式窗口-一个在另一个之上
- 仅使用textbox方法和属性在confirm ok和cancel的代码隐藏中执行不同的代码
- Bootbox jquery中的Javascript函数
- RSpec, capybara, bootbox.js, Rails-3.2.:硒驱动程序的奇怪行为
- Bootbox 4.1.0:如何将本地化字符串(如 Ok、Cancel)传递给 Bootbox 的确认
- Javascript onbeforeunload cancel
- 将自定义类添加到bootbox引导程序jquery插件中的警报对话框中
- javascript确认函数ok和cancel返回相同的结果
- 如何在关闭事件时附加bootbox
- Bootbox:如何添加'提示'
- Bootbox validation
- 无法更改Bootbox中确认框的按钮颜色