如何更改 Google Closure Library ButtonSet
中任何goog.ui.Dialog
的按钮的标题(文字)?
答案 0 :(得分:1)
看起来buttonset对象有一个addButton函数,它将一个对象作为第一个参数:@param {!{key:string,caption:string}}
因此,您所要做的就是使用键(按钮后面的数据)和标题(按钮的实际标签)创建动态对象
var dialog = new goog.ui.Dialog();
dialog.setContent("Content");
// create a button set
var buttonset = new goog.ui.Dialog.ButtonSet();
buttonset.addButton({key: "next", caption: "Next"});
buttonset.addButton({key: "previous", caption: "Previous"});
dialog.setButtonSet(buttonset);
dialog.setVisible(true);
答案 1 :(得分:0)
var dialog1 = new goog.ui.Dialog();
dialog1.setContent('<img src="css/img/warning.png" style="float: right"/>' +
'<div>It is a warning message!</div>');
dialog1.setTitle('Warning');
dialog1.setButtonSet(goog.ui.Dialog.ButtonSet.OK);
dialog1.setVisible(true);
var btnOk = dialog1.getButtonSet().getAllButtons()[0];
btnOk.innerHTML = 'Custome OK';
答案 2 :(得分:0)
您可以更改默认字幕:
goog.ui.Dialog.ButtonSet.DefaultButtons.CANCEL.caption = 'anuluj';
goog.ui.Dialog.ButtonSet.DefaultButtons.OK.caption = 'confirm';