]> source.dussan.org Git - jquery-ui.git/commitdiff
fixed: index and value method will now fire change callback, THX @brunis, see #270
authorFelix Nagel <info@felixnagel.com>
Wed, 10 Oct 2012 08:17:27 +0000 (10:17 +0200)
committerFelix Nagel <info@felixnagel.com>
Wed, 10 Oct 2012 08:17:27 +0000 (10:17 +0200)
ui/jquery.ui.selectmenu.js

index fef37c2b079a8b924128f113a15553dfb8cf8eaa..4c0aa74b0d9434aa2977c62d06e13dcf53fbe1a3 100644 (file)
@@ -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;
                }