2

How can I change the caption (text) of the buttons of any ButtonSet in Google Closure Library goog.ui.Dialog ?

ehsun7b
  • 4,796
  • 14
  • 59
  • 98

3 Answers3

1

Looks like buttonset objects have an addButton function, which takes an object as the first parameter: @param {!{key: string, caption: string}}

So, all you have to do is create on-the-fly objects with a key (the data behind the button) and caption (the actual label of the button)

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);
Joe Heyming
  • 777
  • 6
  • 11
0

You can change default captions:

goog.ui.Dialog.ButtonSet.DefaultButtons.CANCEL.caption = 'anuluj';
goog.ui.Dialog.ButtonSet.DefaultButtons.OK.caption = 'confirm';
Styx
  • 1,303
  • 1
  • 19
  • 30
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';
ehsun7b
  • 4,796
  • 14
  • 59
  • 98