原本的更換語系做法(在更換之後alert按鈕文字並沒有改變 下圖)
bootbox.setDefaults("locale", "zh_TW");
bootbox.alert("Your message here…")
bootbox.confirm("Are you sure?", function(result){ /* your callback code */ })
bootbox.prompt("What is your name?", function(result){ /* your callback code */ })
bootbox.alert
bootbox.confirm
bootbox.prompt
修改方法:
加一層Message來註冊 bootbox.alert、bootbox.confirm、bootbox.prompt。
var Message = {
Show: function (message, callback) {
if (callback == null) {
bootbox.alert({
title: "訊息",
message: message,
buttons: { ok: { label: "確定" } }
});
//bootbox.alert(message);
}
else {
bootbox.alert({
title: "訊息",
message: message,
buttons: { ok: { label: "確定", callback: callback } }
});
//bootbox.alert(message, callback);
}
},
Confirm: function (message, callback) {
if (callback == null) {
console.log("No Callback");
}
else {
bootbox.confirm(message, callback);
}
},
Prompt: function (message, callback) {
if (callback == null) {
console.log("No Callback");
}
else {
bootbox.prompt(message, callback);
}
}
}
使用方法:
Message.Show("Your message here…")
Message.Confirm("Are you sure?", function(result){ /* your callback code */ })
Message.Prompt("What is your name?", function(result){ /* your callback code */ })
完成替換:
將"OK" 換成"確定"




沒有留言:
張貼留言