callback to filter items before adding (#485)

* Add item custom callback

* Minor unit test updates

* Test updates, Changed callback name to more clearly distinguish it's function

* Fix description wording in cypress

* Update README

* Updated filter item callback name to be addItemFilter
This commit is contained in:
Glade 2019-02-12 09:56:21 +11:00 committed by Josh Johnson
parent 619c5d802e
commit 938b65d880

View file

@ -64,6 +64,11 @@
<input class="form-control" id="choices-adding-items-disabled" type="text">
</div>
<div data-test-hook="add-item-callback">
<label for="choices-add-item-callback">Callback on Add Item</label>
<input class="form-control" id="choices-add-item-callback" type="text">
</div>
<div data-test-hook="disabled-via-attr">
<label for="choices-disabled-via-attr">Disabled via attribute</label>
<input class="form-control" id="choices-disabled-via-attr" type="text" disabled>
@ -120,6 +125,12 @@
addItems: false,
});
new Choices('#choices-add-item-callback', {
addItemFilter: function (value) {
return (value !== 'test')
}
});
new Choices('#choices-disabled-via-attr');
new Choices('#choices-prepend-append', {