diff --git a/README.md b/README.md index cc48afdab..fd027a039 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ will be returned. If you target one element, that instance will be returned. renderChoiceLimit: -1, maxItemCount: -1, addItems: true, - addItemFilterFn: null, + addItemFilter: null, removeItems: true, removeItemButton: false, editItems: false, @@ -370,23 +370,29 @@ Pass an array of objects: **Usage:** Whether the scroll position should reset after adding an item. -### addItemFilterFn +### addItemFilter -**Type:** `Function` **Default:** `null` +**Type:** `string | RegExp | Function` **Default:** `null` **Input types affected:** `text` -**Usage:** A filter function that will need to return `true` for a user to successfully add an item. +**Usage:** A RegExp or string (will be passed to RegExp constructor internally) or filter function that will need to return `true` for a user to successfully add an item. **Example:** ```js // Only adds items matching the text test new Choices(element, { - addItemFilterFn: (value) => { - return (value !== 'test'); + addItemFilter: (value) => { + return ['orange', 'apple', 'banana'].includes(value); }; }); + +// only items ending to `-red` +new Choices(element, { + addItemFilter: '-red$'; +}); + ``` ### shouldSort diff --git a/public/index.html b/public/index.html index 579ebfe2f..c943526b5 100644 --- a/public/index.html +++ b/public/index.html @@ -1,590 +1,935 @@ - -
- - -Choices.js is a lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without - the jQuery dependency.
-For all config options, visit the GitHub repo.
- -+ Choices.js is a lightweight, configurable select box/text input + plugin. Similar to Select2 and Selectize but without the jQuery + dependency. +
++ For all config options, visit the + GitHub repo. +
+ +- Interested in writing your own ES6 JavaScript plugins? Check out ES6.io for great tutorials! 💪🏼 + Interested in writing your own ES6 JavaScript plugins? Check out + ES6.io for great + tutorials! 💪🏼
-If the following example do not load, the Discogs rate limit has probably been reached. Try again later!
- - - - - - - - - - -If the following two examples do not load, the Discogs rate limit has probably been reached. Try again later!
- - - - - - - - - - - - - - - - - - - - -Try searching for 'fantastic', "Label 3" should display
- - - -Try searching for 'fantastic', "Label 3" should display
- - - - - - - - -Below is an example of how you could have two select inputs depend on eachother. 'Tube stations' will only be enabled if - the value of 'Cities' is 'London'
- - - - - - -Change the values and press reset to restore to initial state.
- -