Forráskód Böngészése

Merge pull request #1675 from duncansmart/clearing-event

Added `select2-clearing` event
Igor Vaynberg 11 éve
szülő
commit
856af7966f
1 módosított fájl, 5 hozzáadás és 0 törlés
  1. 5 0
      select2.js

+ 5 - 0
select2.js

@@ -2044,6 +2044,11 @@ the specific language governing permissions and limitations under the Apache Lic
         clear: function(triggerChange) {
             var data=this.selection.data("select2-data");
             if (data) { // guard against queued quick consecutive clicks
+                var evt = $.Event("select2-clearing");
+                this.opts.element.trigger(evt);
+                if (evt.isDefaultPrevented()) {
+                    return;
+                }
                 var placeholderOption = this.getPlaceholderOption();
                 this.opts.element.val(placeholderOption ? placeholderOption.val() : "");
                 this.selection.find(".select2-chosen").empty();