github地址:https://harvesthq.github.io/chosen/#change-update-events

Using Chosen is easy as can be.

  1. Download the plugin and copy the chosen files to your app.
  2. Activate the plugin on the select boxes of your choice:
    $(".chosen-select").chosen()
  3. Disco.

Chosen options属性设置

github地址:https://harvesthq.github.io/chosen/options.html

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 n or fewer options.
enable_split_word_search true By default, searching will match on any word within an option tag. Set this option tofalse 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 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_delete true By default, pressing delete/backspace on multiple selects will remove a selected choice. Whenfalse, 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 totrue will show the text and group (if any) of the selected option.

max_shown_results Infinity

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_search false

By default Chosen's search is case-insensitive. Setting this option to
true
makes the search case-sensitive.

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 theinherit_select_classes option is set tofalse.

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 aselected or
deselected parameter that tells you which option was changed).

Note: in order to use change in the Prototype version, you have to include theEvent.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 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');
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.

JQueryUI Chosen插件的更多相关文章

  1. [jQueryUI] – Chosen:select下拉选择框美化插件及问题

    Chosen 是一个支持jquery的select下拉框美化插件,它能让丑陋的.很长的select选择框变的更好看.更方便.不仅如此,它更扩展了select,增加了自动筛选的功能.它可对列表进行分组, ...

  2. 如何在 vue 项目里正确地引用 jquery 和 jquery-ui的插件

    copy内容的网址: https://segmentfault.com/a/1190000007020623 使用vue-cli构建的vue项目,webpack的配置文件是分散在很多地方的,而我们需要 ...

  3. 使用chosen插件实现多级联动和置位

    使用chosen插件实现多级联动和置位 首先写好第一个select,加上onchage属性之后,写onchange方法. <select data-placeholder="选择省份. ...

  4. jquery chosen 插件 动态设置+更新选项值

    我要在表单里使用一个select下拉菜单(是不是multiple无所谓),所以选择了jquery chosen这个插件.现在有一个需求,需要根据表单的另一个域来动态加载该select元素的选项. 1 ...

  5. jquery chosen插件使用及select常用方法

    1.chosen插件使用 chosen插件依赖于jQuery库或prototype,使用之前要先引入jQuery或prototype. 引入jquery插件和chosen插件,对需要美化的下拉框执行c ...

  6. jQueryUI Autocomplete插件使用入门教程(最新版)---------转载

    前言: jQuery,无需多作介绍,相信各位读者都应该接触或使用过了.jQuery UI,简而言之,它是一个基于jQuery的前端UI框架.我们可以使用jQuery + jQuery UI非常简单方便 ...

  7. [js插件]JqueryUI日期插件

    引言 之前使用jqueryUi中的弹出框做了一个可拖拽的弹出登录框,也顺便将里面的常用的日期插件和文本框智能提示插件,也学习了一下. 使用方法 首先在项目中引入以下文件: <!-- 日期插件 默 ...

  8. Jquery select chosen 插件注意点

    <select style="width:200px;" name="carId" data-placeholder="选择车辆牌照" ...

  9. jquery chosen 插件多选初始化

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

随机推荐

  1. Java目录下文件夹的含义和运行机制

    Java安装目录下的各个文件夹的意义 >bin 放置Java所有的可执行文件 >include 一些C语言的头文件 >jre Java的运行环境 >lib Java的类库文件 ...

  2. Java自学-泛型 泛型转型

    Java 中的子类泛型转型成父类泛型 步骤 1 : 对象转型 根据面向对象学习的知识,子类转父类 是一定可以成功的 package generic; import charactor.ADHero; ...

  3. Linux 配置单机yum源--ISO镜像做源

    前提:防火墙关闭.SElinus关闭 1.上传ISO镜像(建议传到home目录下) [root@localhost home]# ls iso/ CentOS-.iso 2.挂载目录 [root@lo ...

  4. 【网易官方】极客战记(codecombat)攻略-森林-流星雨star-shower

    流星雨不仅是一个了不起的现象,而且是获得一些钱的好机会. 简介 流星雨正在下着你的宝石和硬币! 但星形金属不是很长寿,硬币很快就消失了. 宝石不会消失. 使用或语句提取密切的金币或宝石: if ite ...

  5. 第一行代码近期bug及解决

    Android学习笔记(5)----启动 Theme.Dialog 主题的Activity时程序崩溃的解决办法https://www.cnblogs.com/dongling/p/6476308.ht ...

  6. 19)PHP,数组知识

    (1)数组的基础 在PHP中,数组的下标可以是数字,也可以是字符串 在PHP中,数组元素的顺序不是由下标决定的,而是由其加入的的顺序决定 (2)数组定义: array(1,5,11,'abs',tru ...

  7. 0x10 - PostgreSQL 安装之 CentOS7 + Patroni

    PostgreSQL + CentOS7 + Patroni 背景 PostgreSQL 的高可用环境 环境 CentOS 7 pg01 (192.168.1.120) pg02 (192.168.1 ...

  8. Kubernetes系列:Kubernetes Dashboard

    15.1.Dashboard 作为Kube认得Web用户界面,用户可以通过Dashboard在Kubernetes集群中部署容器化的应用,对应用进行问题处理和管理,并对集群本身进行管理.通过Dashb ...

  9. ZJNU 1129 - The sum problem——中级

    枚举区间可能的长度len,将m减去1~len构成的序列和后如果结果是len的倍数,则可以构成答案区间. /* Written By. StelaYuri */ #include<stdio.h& ...

  10. 1051: [HAOI2006]受欢迎的牛 (tarjan强连通分量+缩点)

    题目大意:CodeVs2822的简单版本 传送门 $Tarjan$强连通分量+缩点,若连通块的个数等于一则输出n:若缩点后图中出度为0的点个数为1,输出对应连通块内的点数:否则输出0: 代码中注释部分 ...