Recommend this page to a friend! |
Classes of fathurrahman | mnTemplate | public/asset/vendor/select2/docs/pages/09.tagging/docs.md | Download |
|
Download title: Dynamic option creation taxonomy:
process:
never_cache_twig: trueIn addition to a prepopulated menu of options, Select2 can dynamically create new options from text input by the user in the search box. This feature is called "tagging". To enable tagging, set the <div class="s2-example"> <p>
</p> </div>
Note that when tagging is enabled the user can select from the pre-existing options or create a new option by picking the first choice, which is what the user has typed into the search box so far. Tagging with multi-value select boxesTagging can also be used in multi-value select boxes. In the example below, we set the <div class="s2-example"> <p>
</p> </div>
<script type="text/javascript"> $(".js-example-tags").select2({ tags: true }); </script> Try entering a value that isn't listed in the dropdown - you'll be able to add it as a new option! Automatic tokenization into tagsSelect2 supports ability to add choices automatically as the user is typing into the search field. Try typing in the search field below and entering a space or a comma. The separators that should be used when tokenizing can be specified using the <div class="s2-example"> <p> <select class="js-example-tokenizer form-control" multiple="multiple">
</select> </p> </div> <pre data-fill-from=".js-code-example-tokenizer"></pre> <script type="text/javascript" class="js-code-example-tokenizer"> $(".js-example-tokenizer").select2({
}) </script> Customizing tag creationTag propertiesYou may add extra properties to newly created tags by defining a
Constraining tag creationYou may control when Select2 will allow the user to create a new tag, by adding some logic to
Customizing tag placement in the dropdownYou may control the placement of the newly created option by defining a
|