ButtonSet 的自定义标题

发布于 2024-11-26 07:33:00 字数 140 浏览 1 评论 0原文

如何更改 Google Closure Library goog.ui.DialogButtonSet按钮的标题(文本)代码>?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2024-12-03 07:33:00

看起来按钮集对象有一个 addButton 函数,该函数将一个对象作为第一个参数: @param {!{key: string, title: 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);

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);
救赎№ 2024-12-03 07:33:00
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';
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';
暖风昔人 2024-12-03 07:33:00

您可以更改默认标题:

goog.ui.Dialog.ButtonSet.DefaultButtons.CANCEL.caption = 'anuluj';
goog.ui.Dialog.ButtonSet.DefaultButtons.OK.caption = 'confirm';

You can change default captions:

goog.ui.Dialog.ButtonSet.DefaultButtons.CANCEL.caption = 'anuluj';
goog.ui.Dialog.ButtonSet.DefaultButtons.OK.caption = 'confirm';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文