Recommend this page to a friend! |
Classes of fathurrahman | mnTemplate | public/asset/vendor/select2/docs/pages/07.dropdown/docs.md | Download |
|
Download title: Dropdown taxonomy:
process:
never_cache_twig: trueThis chapter covers the appearance and behavior of the list of results in the dropdown menu. TemplatingBy default, Select2 will display the <div class="s2-example">
</div> <pre data-fill-from=".js-code-example-templating"></pre> <script type="text/javascript" class="js-code-example-templating"> function formatState (state) { if (!state.id) {
} var baseUrl = "{{ url('user://pages/images/flags') }}"; var $state = $(
); return $state; }; $(".js-example-templating").select2({ templateResult: formatState }); </script> The >>> You may find it helpful to use a client-side templating engine like Handlebars to define your templates. Built-in escapingBy default, strings returned by If you need to render HTML with your result template, you must wrap your rendered result in a jQuery object. In this case, the result will be passed directly to >>> Anything rendered in the results is templated. This includes results such as the "Searching..." and "Loading more..." text which will periodically be displayed, which allows you to add more advanced formatting to these automatically generated options. You must ensure that your templating functions can support them. Automatic selectionSelect2 can be configured to automatically select the currently highlighted result when the dropdown is closed by using the
Forcing the dropdown to remain open after selectionSelect2 will automatically close the dropdown when an element is selected, similar to what is done with a normal select box. You may use the
Note that this option is only applicable to multi-select controls. >>> If the Dropdown placement>>>>> Attention Harvest Chosen migrators! If you are migrating to Select2 from Chosen, this option will cause Select2 to position the dropdown in a similar way. By default, Select2 will attach the dropdown to the end of the body and will absolutely position it to appear above or below the selection container. Select2 will display the dropdown above the container if there is not enough space below the container, but there is enough space above it. The
This is useful when attempting to render Select2 correctly inside of modals and other small containers. If you're having trouble using the search box inside a Bootstrap modal, for example, trying setting the If you are rendering a Select2 inside of a modal (Bootstrap 3.x) that has not yet been rendered or opened, you may need to bind to the
If you run into positioning issues while using the default
See this issue. >>>> |