2

如何更改Google Closure Library中任何按钮的标题(文本) ?ButtonSet goog.ui.Dialog

4

3 回答 3

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);
于 2014-03-21T06:54:44.837 回答
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';
于 2011-07-25T12:44:25.100 回答
0

您可以更改默认字幕:

goog.ui.Dialog.ButtonSet.DefaultButtons.CANCEL.caption = 'anuluj';
goog.ui.Dialog.ButtonSet.DefaultButtons.OK.caption = 'confirm';
于 2013-03-18T13:51:51.700 回答