1
0
mirror of synced 2024-11-23 05:26:10 +03:00

Update to unselect method to support "select2-removing" triggers.

The goal here is send off a triggered event to a subscriber that an
element is going to be removed. It hasn't removed yet but would be
after the event fires. I have also added logic to determine if a
subscriber has prevented default. This will prove useful in the future
if a subscriber needs to extend the functionality for other usages.
This commit is contained in:
Andrew Velis 2013-10-07 20:47:12 -07:00
parent f39ab3080e
commit 204d4a276e

View File

@ -2855,7 +2855,15 @@ the specific language governing permissions and limitations under the Apache Lic
this.setVal(val); this.setVal(val);
if (this.select) this.postprocessResults(); if (this.select) this.postprocessResults();
} }
selected.remove();
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.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
this.triggerChange({ removed: data }); this.triggerChange({ removed: data });