mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-19 22:16:33 +02:00
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:
parent
619c5d802e
commit
938b65d880
|
@ -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', {
|
||||
|
|
Loading…
Reference in a new issue