jquery plugins —— Chosen

来源:http://www.cnblogs.com/xbzhu/archive/2016/01/20/5144097.html
-Advertisement-
Play Games

官網地址: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...


官網地址: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%"
  });
OptionDefaultDescription
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>
AttributeDescription
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>
ClassnameDescription
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);
  });
EventDescription
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');
EventDescription
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.

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 1.pom 項目對象模型 (project object model) pom的組成 1.項目基本信息 2.構建環境 --dev,test,beta,prod 3.pom關係 --依賴jar包 4.構建設置 -- plugin 插件2.插件與目標 調用插件目標的兩種方式: ...
  • 1、常用的五種併發包ConcurrentHashMapCopyOnWriteArrayListCopyOnWriteArraySetArrayBlockingQueueLinkedBlockingQueue2、ConcurrentHashMap線程安全的HashMap的實現數據結構:一個指定個數的S...
  • Day2401 TCP上傳圖片02 客戶端併發上傳圖片03 客戶端併發登錄04 瀏覽器客戶端-自定義服務端05 瀏覽器客戶端-Tomcat服務端01 TCP上傳圖片 1 import java.net.*; 2 import java.io.*; 3 class PicClient 4 { 5 .....
  • [1] 比較了常見的應用伺服器和Web伺服器。 [2] 介紹了在項目構建中,應用伺服器和Web伺服器所承擔的不同作用。
  • 設計模式系列都是學習HeadFirst設計模式得出的學習心得,中間的例子也會採用書中的例子。這裡有必要解釋一下,在下麵星巴克咖啡的例子中,有幾種基本的咖啡,還有牛奶、豆漿等等可以向咖啡中添加,這裡說明防止下麵不懂。 今天我們來瞭解一下裝飾者模式。 回想一下java的io包,各種stream排...
  • 工廠模式簡介。工廠模式專門負責將大量有共同介面的類實例化工廠模式可以動態決定將哪一個類實例化,不必事先知道每次要實例化哪一個類。工廠模式有三種形態:1、簡單工廠模式Simple Factory,又稱靜態工廠方法模式2、工廠方法模式Factory Method,又稱多態性工廠模式3、抽象工廠模式Abs...
  • 湯姆大叔的6道js題目 (裡面最有意思的是 實現如下語法的功能:var a = add(2)(3)(4); //9 )
  • mustache.js是一個簡單強大的Javascript模板引擎,使用它可以簡化在js代碼中的html編寫,壓縮後只有9KB,非常值得在項目中使用。本文總結它的使用方法和一些使用心得,內容不算很高深,純粹是入門內容,看看即可。不過要是你還沒有用過此類的javascript引擎庫,那麼本文還是值得你...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...