diff options
author | Felix Nagel <info@felixnagel.com> | 2012-10-10 10:17:27 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2012-10-10 10:17:27 +0200 |
commit | 68b908e76c4ce70539c12cdecc9576a81302f135 (patch) | |
tree | 8aaaf9caad1089124137db73c49cddcb7c906783 | |
parent | c62c6c308072cc8da1dda2d211647b92e580b457 (diff) | |
download | jquery-ui-68b908e76c4ce70539c12cdecc9576a81302f135.tar.gz jquery-ui-68b908e76c4ce70539c12cdecc9576a81302f135.zip |
fixed: index and value method will now fire change callback, THX @brunis, see #270
-rw-r--r-- | ui/jquery.ui.selectmenu.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/ui/jquery.ui.selectmenu.js b/ui/jquery.ui.selectmenu.js index fef37c2b0..4c0aa74b0 100644 --- a/ui/jquery.ui.selectmenu.js +++ b/ui/jquery.ui.selectmenu.js @@ -328,12 +328,8 @@ $.widget("ui.selectmenu", { .data('optionClasses', selectOptionData[i].classes || '') .bind("mouseup.selectmenu", function(event) { if (self._safemouseup && !self._disabled(event.currentTarget) && !self._disabled($( event.currentTarget ).parents( "ul>li." + self.widgetBaseClass + "-group " )) ) { - var changed = $(this).data('index') != self._selectedIndex(); self.index($(this).data('index')); self.select(event); - if (changed) { - self.change(event); - } self.close(event, true); } return false; @@ -793,11 +789,12 @@ $.widget("ui.selectmenu", { } }, - index: function(newValue) { + index: function(newIndex) { if (arguments.length) { - if (!this._disabled($(this._optionLis[newValue]))) { - this.element[0].selectedIndex = newValue; + if (!this._disabled($(this._optionLis[newIndex])) && newIndex != this._selectedIndex()) { + this.element[0].selectedIndex = newIndex; this._refreshValue(); + this.change(); } else { return false; } @@ -807,9 +804,10 @@ $.widget("ui.selectmenu", { }, value: function(newValue) { - if (arguments.length) { + if (arguments.length && newValue != this.element[0].value) { this.element[0].value = newValue; this._refreshValue(); + this.change(); } else { return this.element[0].value; } |