jquery plugins —— Chosen
官网地址: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 |
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 |
| 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 Note: The |
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 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的更多相关文章
- Writing Your Own jQuery Plugins
Setting Up <script src="js/jquery-1.9.1.min.js"></script> <script src=" ...
- 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 ...
- jQuery plugins 图片上传
http://plugins.jquery.com/ 用到一下插件: magnific popup 看大图 jQuery File Upload 多文件上传 jQuery Rotate 图片旋转 gi ...
- jquery plugins
jQuery官网插件 jQuery自定义滚动条样式插件 jQuery custom content scroller examples Twitter typeahead typeahead.js t ...
- jquery plugins —— datatables 搜索后汇总
网上的例子 http://datatables.club/example/plug-ins/api.html只能对当前页面或所有数据进行汇总,不能对搜索结果数据汇总. 以下是对datatables自带 ...
- Best jQuery Plugins of the Month – May 2014
1. jQuery referenceSection jQuery referenceSection by Scott Mascio ensures to help users in adding a ...
- Jquery Plugins Jquery Validate
Jquery Validate 一.什么是Jquery Validate: jQuery Validate 插件为表单提供了强大的验证功能. 二.常用值: 1 required:true 必须输入 ...
- jquery select chosen禁用某一项option
$("#tbParBudCode").chosen().change(function () { $("#tbParBudCode option[value='" ...
- jquery select chosen 动态绑定值
$("#ddlMstData").find("option[value=" + data.MstKey + "]").attr(" ...
随机推荐
- 手把手教你玩转SOCKET模型之重叠I/O篇(下)
四. 实现重叠模型的步骤 作 了这么多的准备工作,费了这么多的笔墨,我们终于可以开始着手编码了.其实慢慢的你就会明白,要想透析重叠结构的内部原理也许是要费点功夫,但是只是学会 如何来使用它,却 ...
- Objective-C 学习记录--toches、Motion/Size/Rect/Point/CGFloat/protocol
- (void)touchesBegan touchesEnd touchesCancelled touchesMoved //代表的是手指在屏幕上的动作,开始 结束 取消 移动 //还有就是代表摇动 ...
- user is not in the sudoers file.This incident will be reported
我用普通用户ssk登陆,想让ssk成为拥有超级用户的权限的普通用户 开始提示输入密码错误 ,然后就这样了 解决方法如下: 1>.进入超级用户模式.也就是输入"su -", ...
- sql 分组后 组内排名
语法:ROW_NUMBER() OVER(PARTITION BY COLUMN ORDER BY COLUMN) 简单的说row_number()从1开始,为每一条分组记录返回一个数字,这里的ROW ...
- 【转】Android 实现蘑菇街购物车动画效果
原文出处:http://blog.csdn.net/wangjinyu501/article/details/38400479 1.思路 目前想到两种方式实现这种效果,一是使用Tween动画,直截 ...
- android ListView中的Item有Button时候点击异常处理
1.当ListView中有Button的时候往往会遇到很多问题,比较常见的一个问题是: 假设:在ListView中有N个Item当点击其中某个Item中的Button的时候,需要改变当前Button的 ...
- 关于pushState
window.pushState({}, "title", "/index.html");---------------->改变URL的值,但是并不刷新 ...
- [Angular2 Form] Build Select Dropdowns for Angular 2 Forms
Select Dropdowns in Angular 2 a built with select and option elements. You use *ngFor to loop throug ...
- 【React Native 实战】旋转图片验证码
1.前言蘑菇街用打乱方向的图片作为验证码,既起到了验证码的作用又宣传了图片,今天我们就用React Native来实现这样的功能. 2.属性 Image标签属性resizeMode enum('cov ...
- 高级Swing——列表
1. 列表 1.1 JList构件 JList可以将多个选项放置在单个框中.为了构建列表框,首先需要创建一个字符串数组,然后将这个数组传递给JList构造器. String[] words= { &q ...