Selectize.js: add a category label to the selection

selectize.js

Can I add an unselected category (label) to the input selection?

enter image description here

The problem is that I have a large list of inputs, and it would be great to add categories (tags) to the selection. Like this:

Category 1
---Item1
---Item2
---Item3
---Item4
Category 2
---Item5
---Item6
---Item7
---Item8
...etc
+4
source share
2 answers

You can enable the creation of tags and a group of parameters. It seems to work here .

Use an element select, with optgroupfor categories:

<select id="select-gear" class="demo-default" multiple placeholder="Select gear...">
    <option value="">Select gear...</option>
    <optgroup label="Climbing">
        <option value="pitons">Pitons</option>
        <option value="sling">Sling</option>
    </optgroup>
    <optgroup label="Skiing">
        <option value="skis">Skis</option>
        <option value="skins">Skins</option>
        <option value="poles">Poles</option>
    </optgroup>
</select>

When initializing, use the option create : true:

$('#select-gear').selectize({
    create: true
});
+2
source

Support Choice <optgroup>

enter image description here

+1
source

Source: https://habr.com/ru/post/1611504/


All Articles