Merge pull request #915 from PVince81/triggerchangeflagforclear
triggerChange flag when calling clear() from val() with empty value
This commit is contained in:
commit
55b8176c04
@ -1747,7 +1747,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
},
|
},
|
||||||
|
|
||||||
// single
|
// single
|
||||||
clear: function() {
|
clear: function(triggerChange) {
|
||||||
var data=this.selection.data("select2-data");
|
var data=this.selection.data("select2-data");
|
||||||
if (data) { // guard against queued quick consecutive clicks
|
if (data) { // guard against queued quick consecutive clicks
|
||||||
this.opts.element.val("");
|
this.opts.element.val("");
|
||||||
@ -1755,9 +1755,11 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
this.selection.removeData("select2-data");
|
this.selection.removeData("select2-data");
|
||||||
this.setPlaceholder();
|
this.setPlaceholder();
|
||||||
|
|
||||||
|
if (triggerChange !== false){
|
||||||
this.opts.element.trigger({ type: "removed", val: this.id(data), choice: data });
|
this.opts.element.trigger({ type: "removed", val: this.id(data), choice: data });
|
||||||
this.triggerChange({removed:data});
|
this.triggerChange({removed:data});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1946,7 +1948,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
}
|
}
|
||||||
// val is an id. !val is true for [undefined,null,'',0] - 0 is legal
|
// val is an id. !val is true for [undefined,null,'',0] - 0 is legal
|
||||||
if (!val && val !== 0) {
|
if (!val && val !== 0) {
|
||||||
this.clear();
|
this.clear(triggerChange);
|
||||||
if (triggerChange) {
|
if (triggerChange) {
|
||||||
this.triggerChange();
|
this.triggerChange();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user