diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-11-15 22:51:26 +0100 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-11-26 10:28:22 +0100 |
commit | fed2972027f362181a614750fbaa7e252d1c1cb2 (patch) | |
tree | e123a9296a516486804350d303b8977e9b12813d | |
parent | 83a9f219bf40ff834d660020bbfa7de550e48a0c (diff) | |
download | jquery-ui-fed2972027f362181a614750fbaa7e252d1c1cb2.tar.gz jquery-ui-fed2972027f362181a614750fbaa7e252d1c1cb2.zip |
Dialog: Refactor _setOption to call _super early. Move dialogClass update above that to access old option value.
-rw-r--r-- | tests/unit/dialog/dialog_options.js | 5 | ||||
-rw-r--r-- | ui/jquery.ui.dialog.js | 15 |
2 files changed, 12 insertions, 8 deletions
diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index 2df7196dc..0be8c2b7f 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -148,7 +148,7 @@ test("closeText", function() { }); test("dialogClass", function() { - expect(4); + expect( 6 ); var el = $('<div></div>').dialog(); equal(el.dialog('widget').is(".foo"), false, 'dialogClass not specified. foo class added'); @@ -156,6 +156,9 @@ test("dialogClass", function() { el = $('<div></div>').dialog({ dialogClass: "foo" }); equal(el.dialog('widget').is(".foo"), true, 'dialogClass in init. foo class added'); + el.dialog( "option", "dialogClass", "foobar" ); + equal( el.dialog('widget').is(".foo"), false, "dialogClass changed, previous one was removed" ); + equal( el.dialog('widget').is(".foobar"), true, "dialogClass changed, new one was added" ); el.remove(); el = $('<div></div>').dialog({ dialogClass: "foo bar" }); diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 055040b32..cb4230eac 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -565,6 +565,14 @@ $.widget("ui.dialog", { var isDraggable, isResizable, uiDialog = this.uiDialog; + if ( key === "dialogClass" ) { + uiDialog + .removeClass( this.options.dialogClass ) + .addClass( value ); + } + + this._super( key, value ); + switch ( key ) { case "buttons": this._createButtons( value ); @@ -575,11 +583,6 @@ $.widget("ui.dialog", { label: "" + value }); break; - case "dialogClass": - uiDialog - .removeClass( this.options.dialogClass ) - .addClass( value ); - break; case "disabled": // TODO use toggleClass( "ui-dialog-disabled", value ) if ( value ) { @@ -625,8 +628,6 @@ $.widget("ui.dialog", { .html( "" + ( value || " " ) ); break; } - - this._super( key, value ); }, _size: function() { |