소스 검색

fire selected before close. #835

Igor Vaynberg 12 년 전
부모
커밋
6c9aef4bb3
1개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 5 4
      select2.js

+ 5 - 4
select2.js

@@ -1846,13 +1846,14 @@ the specific language governing permissions and limitations under the Apache Lic
 
             this.opts.element.val(this.id(data));
             this.updateSelection(data);
+
+            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
+
             this.close();
 
             if (!options || !options.noFocus)
                 this.selection.focus();
 
-            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
-
             if (!equal(old, this.id(data))) { this.triggerChange(); }
         },
 
@@ -2233,6 +2234,8 @@ the specific language governing permissions and limitations under the Apache Lic
         onSelect: function (data, options) {
             this.addSelectedChoice(data);
 
+            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
+
             if (this.select || !this.opts.closeOnSelect) this.postprocessResults();
 
             if (this.opts.closeOnSelect) {
@@ -2255,8 +2258,6 @@ the specific language governing permissions and limitations under the Apache Lic
                 }
             }
 
-            this.opts.element.trigger({ type: "selected", val: this.id(data), choice: data });
-
             // since its not possible to select an element that has already been
             // added we do not need to check if this is a new element before firing change
             this.triggerChange({ added: data });