Skip to content

Commit 96e019c

Browse files
committed
update and extend docs related to options item builder
1 parent 4672246 commit 96e019c

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

public/index.html

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,37 @@ <h2>Options</h2>
254254

255255
/*
256256
* Type: String or Function
257-
* Description: Define how each option should be rendered inside its <li> element.
257+
* Description: Define how each option should be rendered inside its &lt;li&gt; element.
258258
*
259259
* If it's a string, all keys wrapped in brackets will be replaced by
260260
* the respective values in itemData. Available keys are:
261-
* 'value', 'text', 'slug', 'disabled'.
261+
* 'value', 'text', 'slug', 'index'.
262262
*
263-
* If it's a function, it will be called with the following parameters:
264-
* (itemData, element, index). The function must return a string,
265-
* no keys will be replaced in this method.
263+
* If it's a function, it will be called with the following parameter:
264+
* (itemData). The function must return a string. If available all keys
265+
* will be replaced by the respective values in itemData.
266+
*
267+
* itemData&lt;Object&gt; {
268+
* className // Type: String. Description: option class names.
269+
* disabled // Type: Boolean. Description: option is disabled true/false
270+
* selected // Type: Boolean. Description: option is selected true/false
271+
* element // Type: HTMLDomElement. Description: current select element
272+
* index // Type: Number. Description: current option index
273+
* slug // Type: String. Description: option slug
274+
* text // Type: String. Description: option text
275+
* value // Type: String. Description: option value
276+
* }
277+
*
278+
* EXAMPLE:
279+
*
280+
* function(itemData) {
281+
* return '<span class="item-{index}">{text}</span>';
282+
* }
283+
*
284+
* // you're free to build and return your own strings
285+
* function(itemData) {
286+
* return itemData.text + '(' + itemData.index + ')';
287+
* }
266288
*/
267289
optionsItemBuilder: '{text}',
268290

0 commit comments

Comments
 (0)