【问题标题】:Custom Caption for ButtonSetButtonSet 的自定义标题
【发布时间】:2011-07-25 11:54:43
【问题描述】:

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

【问题讨论】:

    标签: button dialog google-closure google-closure-library


    【解决方案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);
    

    【讨论】:

      【解决方案2】:
      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';
      

      【讨论】:

        【解决方案3】:

        您可以更改默认字幕:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-04-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-01-09
          • 2013-09-02
          • 2015-05-07
          • 1970-01-01
          相关资源
          最近更新 更多