From 2beadad730ecf2e1dd9f050a5ae61928f61abb94 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Sat, 20 Jul 2013 13:05:03 +0000 Subject: [PATCH] Make sure dialog is created before trying to update buttons --- etemplate/js/et2_widget_dialog.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/etemplate/js/et2_widget_dialog.js b/etemplate/js/et2_widget_dialog.js index dbc6508fac..8ecc9dab52 100644 --- a/etemplate/js/et2_widget_dialog.js +++ b/etemplate/js/et2_widget_dialog.js @@ -321,11 +321,7 @@ var et2_dialog = et2_widget.extend({ */ set_buttons: function(buttons) { this.options.buttons = buttons; - if(typeof buttons == "number" && typeof this._buttons[buttons] != "undefined") - { - this.div.dialog("option", "buttons", this._buttons[buttons]); - } - else if (buttons instanceof Array) + if (buttons instanceof Array) { for (var i = 0; i < buttons.length; i++) { @@ -335,10 +331,16 @@ var et2_dialog = et2_widget.extend({ } } this.options.buttons = buttons; - this.div.dialog("option", "buttons", buttons); } - // Focus default button so enter works - $j('.ui-dialog-buttonpane button[default]',this.div.parent()).focus(); + + // If dialog already created, update buttons + if(this.div.data('uiDialog')) + { + this.div.dialog("option", "buttons", buttons); + + // Focus default button so enter works + $j('.ui-dialog-buttonpane button[default]',this.div.parent()).focus(); + } }, /**