input-pill: Add clean up functions.

This adds functions to remove pills and reset the state.
This commit is contained in:
Brock Whittaker
2017-11-10 13:11:01 -08:00
committed by Tim Abbott
parent 70a14d8b44
commit 5ae4b8d3f3

View File

@@ -150,6 +150,14 @@ var input_pill = function ($parent) {
}
},
removeAllPills: function () {
while (store.pills.length > 0) {
this.removeLastPill();
}
this.clear(store.$parent.find(".input"));
},
// returns all data of the pills exclusive of their elements.
data: function () {
return store.pills.map(function (pill) {
@@ -314,6 +322,8 @@ var input_pill = function ($parent) {
validate: function (callback) {
store.validation = callback;
},
clear: funcs.removeAllPills.bind(funcs),
};
return prototype;