官网地址:http://harvesthq.github.io/chosen/

Chosen (v1.4.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%"
});
Option Default Description
allow_single_deselect false When set to true on a single select, Chosen adds a UI element which selects the first element (if it is blank).
disable_search false When set to true, Chosen will not display the search field (single selects only).
disable_search_threshold 0 Hide the search input on single selects if there are fewer than (n) options.
enable_split_word_search true By 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_classes false When set to true, Chosen will grab any classes on the original select field and add them to Chosen’s container div.
max_selected_options Infinity Limits 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_contains false By default, Chosen’s search matches starting at the beginning of a word. Setting this option to true 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_delete true By 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.
width Original 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_options true By 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_options true

By 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_selected false

By 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.

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>
Attribute Description
data-placeholder

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 the placeholder_text_multiple or placeholder_text_single options.

multiple The attribute multiple on your select box dictates whether Chosen will render a multiple or single select.
selected, disabled Chosen 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>
Classname Description
chosen-rtl

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.

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);
});
Event Description
change

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: in order to use change in the Prototype version, you have to include the Event.simulate class. The selected and deselected parameters are not available for Prototype.

chosen:ready Triggered after Chosen has been fully instantiated.
chosen:maxselected Triggered if max_selected_options is set and that total is broken.
chosen:showing_dropdown Triggered when Chosen’s dropdown is opened.
chosen:hiding_dropdown Triggered when Chosen’s dropdown is closed.
chosen:no_results Triggered when a search returns no matching results.

Note: all custom Chosen events (those that being 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');
Event Description
chosen:updated This event should be triggered whenever Chosen’s underlying select element changes (such as a change in selected options).
chosen:activate This is the equivalant of focusing a standard HTML select field. When activated, Chosen will capure keypress events as if you had clicked the field directly.
chosen:open This event activates Chosen and also displays the search results.
chosen:close This event deactivates Chosen and hides the search results.

jquery plugins —— Chosen的更多相关文章

  1. Writing Your Own jQuery Plugins

    Setting Up <script src="js/jquery-1.9.1.min.js"></script> <script src=" ...

  2. jsDelivr - Free open source CDN for javascript libraries, jQuery plugins, CSS frameworks, Fonts and more

    jsDelivr - Free open source CDN for javascript libraries, jQuery plugins, CSS frameworks, Fonts and ...

  3. jQuery plugins 图片上传

    http://plugins.jquery.com/ 用到一下插件: magnific popup 看大图 jQuery File Upload 多文件上传 jQuery Rotate 图片旋转 gi ...

  4. jquery plugins

    jQuery官网插件 jQuery自定义滚动条样式插件 jQuery custom content scroller examples Twitter typeahead typeahead.js t ...

  5. jquery plugins —— datatables 搜索后汇总

    网上的例子 http://datatables.club/example/plug-ins/api.html只能对当前页面或所有数据进行汇总,不能对搜索结果数据汇总. 以下是对datatables自带 ...

  6. Best jQuery Plugins of the Month – May 2014

    1. jQuery referenceSection jQuery referenceSection by Scott Mascio ensures to help users in adding a ...

  7. Jquery Plugins Jquery Validate

      Jquery Validate 一.什么是Jquery Validate: jQuery Validate 插件为表单提供了强大的验证功能. 二.常用值: 1 required:true 必须输入 ...

  8. jquery select chosen禁用某一项option

    $("#tbParBudCode").chosen().change(function () { $("#tbParBudCode option[value='" ...

  9. jquery select chosen 动态绑定值

    $("#ddlMstData").find("option[value=" + data.MstKey + "]").attr(" ...

随机推荐

  1. apache与IIS端口冲突修改和需要使用 SSL 查看该资源”错误

    改变Apache端口等配置修改方法 www.educity.cn 发布者:jsb200421 来源:网络转载 发布日期:2014年01月02日 如何改变Apache端口:找到Apache安装目录下co ...

  2. Minus-C 一个最小化的C语言规范

    资深C++程序员都不会对C++编程规范太陌生,C++实在太复杂,以至于所有项目都需要裁剪一个子集共项目组内使用.经过在家休息这一小段时间,我发现其实C语言更需要一个相同的规范,这就是本文的目标,最大可 ...

  3. 如何解除Windows XP的IIS连接数限制

    方法一: 开始 - 设置 - 控制面板 - 管理工具 - Internet 信息服务 - 默认网站 - 右键属性,把“网站”选项卡中“连接超时”下的复选框"保持HTTP连接"前的勾 ...

  4. SecureCRT上传、下载文件(使用sz与rz命令)

    1.简述 借助securtCRT,使用linux命令sz可以很方便的将服务器上的文件下载到本地,使用rz命令则是把本地文件上传到服务器. 2.理解记忆 其中,对于sz和rz的理解与记忆我用了如下的方法 ...

  5. poj 3134 Power Calculus(IDA*)

    题目大意: 用最小的步数算出  x^n 思路: 直接枚举有限步数可以出现的所有情况. 然后加一个A*   就是如果这个数一直平方  所需要的步骤数都不能达到最优   就剪掉 #include < ...

  6. UVA1151

    //感觉刘汝佳老师的思维真的太厉害了orz /*摘录书上的一段话: 只需一个小小的优化即可降低时间复杂度:先求一次原图(不购买任何套餐)的最小生 成树,得到n-1条边,然后每次枚举完套餐后只考虑套餐中 ...

  7. 不用FTP使用SecureCRT上传下载文件,并解决rz、sz command not found异常

    使用SSH终端操作Linux/UNIX时,很多时候需要传一些文件到服务器上,或说从服务器上下载一些文件,这类文件传输动作一般使用FTP即可,但是需要架设FTP Server,每次传输不太方便,还要另外 ...

  8. HDU 5597 GTW likes function 打表

    GTW likes function 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5596 Description Now you are give ...

  9. !"false"==fasle

    首先要搞清楚优先级 !"false" --->false false == false;---->true !""--->true; !&qu ...

  10. iOS 原生地图(MapKit、MKMapView)轨迹渐变

    WechatIMG2.png 项目已接入高德地图,并且大部分功能已经实现好,但BOSS觉得iOS自带的地图效果更好...本着面向老板编程的思想,换之.还好,高德地图是在MapKit上封装的,大部分ap ...