jquery chosen api
来源:互联网 发布:国家电网网络大学登录 编辑:程序博客网 时间:2024/05/19 06:19
Chosen (v1.8.2)
Chosen has a number of options and attributes that allow you to have full control of your select boxes.
Options
The following options are available to pass into Chosen on instantiation.
Example:
$(".my_select_box").chosen({ disable_search_threshold: 10, no_results_text: "Oops, nothing found!", width: "95%" });
true
on a single select, Chosen adds a UI element which selects the first element (if it is blank).disable_searchfalseWhen set to true
, Chosen will not display the search field (single selects only).disable_search_threshold0Hide the search input on single selects if there are n or fewer options.enable_split_word_searchtrueBy default, searching will match on any word within an option tag. Set this option to false
if you want to only match on the entire text of an option tag.inherit_select_classesfalseWhen set to true
, Chosen will grab any classes on the original select field and add them to Chosen’s container div.max_selected_optionsInfinityLimits how many options the user can select. When the limit is reached, the chosen:maxselected
event is triggered.no_results_text"No results match"The text to be displayed when no matching results are found. The current search is shown at the end of the text (e.g., No results match "Bad Search").placeholder_text_multiple"Select Some Options"The text to be displayed as a placeholder when no options are selected for a multiple select.placeholder_text_single"Select an Option"The text to be displayed as a placeholder when no options are selected for a single select.search_containsfalseBy default, Chosen’s search matches starting at the beginning of a word. Setting this option totrue
allows matches starting from anywhere within a word. This is especially useful for options that include a lot of special characters or phrases in ()s and []s.single_backstroke_deletetrueBy default, pressing delete/backspace on multiple selects will remove a selected choice. When false
, pressing delete/backspace will highlight the last choice, and a second press deselects it.widthOriginal select width.The width of the Chosen select box. By default, Chosen attempts to match the width of the select box you are replacing. If your select is hidden when Chosen is instantiated, you must specify a width or the select will show up with a width of 0.display_disabled_optionstrueBy default, Chosen includes disabled options in search results with a special styling. Setting this option to false will hide disabled results and exclude them from searches.display_selected_optionstrueBy default, Chosen includes selected options in search results with a special styling. Setting this option to false will hide selected results and exclude them from searches.
Note: this is for multiple selects only. In single selects, the selected result will always be displayed.
include_group_label_in_selectedfalseBy default, Chosen only shows the text of a selected option. Setting this option to true
will show the text and group (if any) of the selected option.
Only show the first (n) matching options in the results. This can be used to increase performance for selects with very many options.
case_sensitive_searchfalseBy default Chosen's search is case-insensitive. Setting this option to true
makes the search case-sensitive.
By default Chosen's results are hidden after a option is selected. Setting this option to false
will keep the results open after selection. This only applies to multiple selects.
Chosen supports right-to-left text in select boxes. Set this option to true
to support right-to-left text options.
Note: the chosen-rtl
class on the select has precedence over this option. However, the classname approach is deprecated and will be removed in future versions of Chosen.
Attributes
Certain attributes placed on the select tag or its options can be used to configure Chosen.
Example:
<select class="my_select_box" data-placeholder="Select Your Options"> <option value="1">Option 1</option> <option value="2" selected>Option 2</option> <option value="3" disabled>Option 3</option> </select>
The text to be displayed as a placeholder when no options are selected for a select. Defaults to "Select an Option" for single selects or "Select Some Options" for multiple selects.
Note:This attribute overrides anything set in theplaceholder_text_multiple
or placeholder_text_single
options.
multiple
on your select box dictates whether Chosen will render a multiple or single select.selected, disabledChosen automatically highlights selected options and disables disabled options.Classes
Classes placed on the select tag can be used to configure Chosen.
Example:
<select class="my_select_box chosen-rtl"> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> </select>
Chosen supports right-to-left text in select boxes. Add the class chosen-rtl
to your select tag to support right-to-left text options.
Note: The chosen-rtl
class will pass through to the Chosen select even when the inherit_select_classes
option is set to false
.
Note: This is deprecated in favor of using the rtl:true
option (see theOptions section).
Triggered Events
Chosen triggers a number of standard and custom events on the original select field.
Example:
$('.my_select_box').on('change', function(evt, params) { do_something(evt, params); });
Chosen triggers the standard DOM event whenever a selection is made (it also sends a selected
or deselected
parameter that tells you which option was changed).
Note: The selected and deselected parameters are not available for Prototype.
chosen:readyTriggered after Chosen has been fully instantiated.chosen:maxselectedTriggered ifmax_selected_options
is set and that total is broken.chosen:showing_dropdownTriggered when Chosen’s dropdown is opened.chosen:hiding_dropdownTriggered when Chosen’s dropdown is closed.chosen:no_resultsTriggered when a search returns no matching results.Note: all custom Chosen events (those that begin with chosen:
) also include the chosen
object as a parameter.
Triggerable Events
You can trigger several events on the original select field to invoke a behavior in Chosen.
Example:
// tell Chosen that a select has changed $('.my_select_box').trigger('chosen:updated');
- jquery chosen api
- chosen jquery
- chosen.jquery
- jquery select 插件 chosen
- jquery Chosen使用
- jquery chosen 插件
- jquery Chosen使用
- jquery chosen 三级联动
- jquery chosen 插件使用
- jquery-chosen设置默认值
- Jquery chosen动态设置值
- jquery插件chosen的使用
- jquery-chosen 选择框插件
- jquery-chosen 选择框插件
- jQuery chosen下拉框检索
- 如何获取 chosen chosen.jquery.js 选中的值
- chosen.jquery.js 搜索框实现模糊搜索 chosen-select
- 如何获取 chosen chosen.jquery.js 选中的值
- 给定一个可能包含重复的整数的集合,S返回所有可能的子集。
- HTTP中PUT和POST的区别
- Android 6.0以上权限处理
- MAC同时通过有线和无线访问内外网的设置方法
- 原样输出html
- jquery chosen api
- 3.线程的状态转换
- [LeetCode]206. Reverse Linked List
- tensorboard的使用
- 简单日食效果实现
- 普元EOSPlatform7.5补丁列表
- linux命令及命令缩写的意思
- mysql load data infile之bit类型数据的处理
- 链式前向星