Jelajahi Sumber

Merge pull request #1774 from avelis/master

Fix for #1518. Update to select2.js to trigger properly named event.
Igor Vaynberg 11 tahun lalu
induk
melakukan
58f939ef3b
1 mengubah file dengan 10 tambahan dan 2 penghapusan
  1. 10 2
      select2.js

+ 10 - 2
select2.js

@@ -2883,9 +2883,17 @@ the specific language governing permissions and limitations under the Apache Lic
                 this.setVal(val);
                 if (this.select) this.postprocessResults();
             }
-            selected.remove();
 
-            this.opts.element.trigger({ type: "removed", val: this.id(data), choice: data });
+            var evt = $.Event("select2-removing");
+            evt.val = this.id(data);
+            evt.choice = data;
+            this.opts.element.trigger(evt);
+
+            if (evt.isDefaultPrevented()) {
+                return;
+            }
+
+            this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
             this.triggerChange({ removed: data });
         },