如何在goog.ui.Dialog中禁用关闭按钮?

时间:2012-06-15 21:37:25

标签: google-closure-library

我想摆脱Google Closure对话框右上角的关闭/ X按钮。

我正在浏览文档(http://closure-library.googlecode.com/svn-history/r8/trunk/closure/goog/docs/class_goog_ui_Dialog.html),但找不到这样做的方法。

2 个答案:

答案 0 :(得分:4)

方法就在那里!见http://closure-library.googlecode.com/svn/docs/class_goog_ui_Dialog.html

dialog.setHasTitleCloseButton(false);

此致

答案 1 :(得分:2)

首先调用goog.ui.Dialog后跟goog.ui.Dialog.prototype.getTitleCloseElement(),即可停用goog.style.showElement(el, display)标题栏关闭按钮。

示例

var dialog = new goog.ui.Dialog();
dialog.setContent('Lorem ipsum dolor sit amet, consectetuer' +
    'adipiscing elit. Aenean sollicitudin ultrices urna. Proin vehicula ' +
    'mauris ac est. Ut scelerisque, risus ut facilisis dictum, est massa ' +
    'lacinia lorem, in fermentum purus ligula quis nunc. Duis porttitor ' +
    'euismod risus. Nam hendrerit lacus vehicula augue. Duis ante.');
dialog.setTitle('Lorem ipsum');
dialog.setButtonSet(goog.ui.Dialog.ButtonSet.createYesNo());

var titleCloseEl = dialog.getTitleCloseElement();
goog.style.showElement(titleCloseEl, false);