From c2903d5c42f3723cdf98a5310707a9f10bc96dbd Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 17 Jan 2009 21:31:43 +0000 Subject: Dialog: Fixed #3688: Don't add the button pane div if there are no buttons. --- ui/ui.dialog.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'ui') diff --git a/ui/ui.dialog.js b/ui/ui.dialog.js index bd5d3b850..0489844f2 100644 --- a/ui/ui.dialog.js +++ b/ui/ui.dialog.js @@ -126,15 +126,7 @@ $.widget("ui.dialog", { .addClass('ui-dialog-title') .attr('id', titleId) .html(title) - .prependTo(uiDialogTitlebar), - - uiDialogButtonPane = (this.uiDialogButtonPane = $('
')) - .addClass( - 'ui-dialog-buttonpane ' + - 'ui-widget-content ' + - 'ui-helper-clearfix' - ) - .appendTo(uiDialog); + .prependTo(uiDialogTitlebar); uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection(); @@ -256,14 +248,19 @@ $.widget("ui.dialog", { _createButtons: function(buttons) { var self = this, hasButtons = false, - uiDialogButtonPane = this.uiDialogButtonPane; + uiDialogButtonPane = $('
') + .addClass( + 'ui-dialog-buttonpane ' + + 'ui-widget-content ' + + 'ui-helper-clearfix' + ); - // remove any existing buttons - uiDialogButtonPane.empty().hide(); + // if we already have a button pane, remove it + this.uiDialog.find('.ui-dialog-buttonpane').remove(); - $.each(buttons, function() { return !(hasButtons = true); }); + (typeof buttons == 'object' && buttons !== null && + $.each(buttons, function() { return !(hasButtons = true); })); if (hasButtons) { - uiDialogButtonPane.show(); $.each(buttons, function(name, fn) { $('') .addClass( @@ -288,6 +285,7 @@ $.widget("ui.dialog", { }) .appendTo(uiDialogButtonPane); }); + uiDialogButtonPane.appendTo(this.uiDialog); } }, -- cgit v1.2.3