Jquery.select2 Fuzzy Query

Source: Internet
Author: User

<! DOCTYPE html>

<meta charset= "Utf-8"/>
<link rel= "stylesheet" type= "Text/css" href= "Css/bootstrap.min.css"/>
<link rel= "stylesheet" href= "Css/bootstrap-table.css"/>
<link rel= "stylesheet" type= "Text/css" href= "Css/select2.min.css"/>
<link rel= "stylesheet" type= "Text/css" href= "Css/index.css"/>
<script src= "Js/jquery-1.11.3.js" type= "Text/javascript" charset= "Utf-8" ></script>
<script src= "Js/select2.min.js" type= "Text/javascript" charset= "Utf-8" ></script>
<script src= "Js/zh-cn.js" type= "Text/javascript" charset= "Utf-8" ></script>
<title></title>
<script>
$ (function () {
$ ("#demo"). Select2 ({
Theme: "Classic",
Tags:true,
Width: "200",
Maximumselectionlength:1
});
});
</script>
<body>
<p>
<!--<input type= "text" class= "Select2-container select2-container--classic select2-container--open" name= "" id = "Value=" "/>-->
<select id= "Demo" class= "Js-example-theme-multiple js-states form-control select2-hidden-accessible" multiple= "" tabindex= "-1" aria-hidden= "true" >
<optgroup label= "Alaskan/hawaiian time Zone" >
<option value= "AK" >Alaska</option>
<option value= "HI" >Hawaii</option>
</optgroup>
<optgroup label= "Pacific time Zone" >
<option value= "CA" >California</option>
<option value= "NV" >Nevada</option>
<option value= "OR" >Oregon</option>
<option value= "WA" >Washington</option>
</optgroup>
<optgroup label= "Mountain time Zone" >
<option value= "AZ" >Arizona</option>
<option value= "CO" >Colorado</option>
<option value= "ID" >Idaho</option>
<option value= "MT" >Montana</option>
<option value= "NE" >Nebraska</option>
</optgroup>
<optgroup label= "Eastern time Zone" >
<option value= "SC" >south carolina</option>
<option value= "VT" >Vermont</option>
<option value= "VA" >Virginia</option>
<option value= "WV" >west virginia</option>
</optgroup>
</select>
</p>
</body>

You can modify the style yourself

Specific parameters can refer to:

Parameters

Type

Describe

Width

String

Select2 container div for controlling width style properties

Minimuminputlength

Int

Minimum number of characters

Maximuminputlength

Int

Maximum number of characters

Minimumresultsforsearch

Int

Minimum number of results

Maximumselectionsize

Int

Maximum number of entries that can be selected

Placeholder

String

Select an initial value

Separator

String

delimiter character or string used to delimit ID

Allowclear

Boolean

This option specifies only placeholders

Multiple

Boolean

Select2 whether to allow multiple values to be selected

Openonenter

Open the drop-down if set to True when the user presses the ENTER key, Select2 closes. This option is enabled by default.

Id

Function

The function is used to get the key that the ID store represents from the Selection object or string ID

Matcher

Function

Used to determine whether a search term matches an option when using a built-in query function

Sortresults

Function

The results to be displayed before sorting the list search.

Formatselection

Function

function to render the current selection

FormatResult

Function

function to render the result,

Formatresultcssclass

Function

function to add CSS class result elements

Formatnomatches

string/function

The string contains a "mismatch" message, or
function is used to render information

Formatsearching

string/function

String contains "search ... "Message, or
The function is used to render the displayed message in the search.

Formatajaxerror

string/function

The string contains the message "Failed to load", or
function is used to render information

Formatinputtooshort

string/function

String containing "search" input too short message, or
function is used to render information.

Formatinputtoolong

string/function

String containing "search" input too short message, or
function is used to render information

Formatinputtoolong

string/function

Contains the "Search input string too long" message, or
function is used to render information.

Formatselectiontoobig

string/function

The string contains "You cannot select any more choices" message, or
function is used to render information

Formatloadmore

string/function

string/function

Createsearchchoice

Function

Create a new optional selection from the user's search term. Allows creation of a select unavailable feature through a query. Useful users can create dynamic selections, such as "tags" usecase.

Createsearchchoiceposition

function/String

Defines the location of the Insert element

Initselection

Function

Call Select2 to create a value that allows the user to initialize the selected Select2 attached to the element

Tokenizer

Function

The token-giving function can be processed after inputting each keystroke and extracting and selecting selection of the input search box.

Tokenseparators

Function

A string array that defines the delimiter word breaker feature marked as the default. By default, this option is set to an empty array tag, which means that using the default compiler is disabled. It is usually wise to set this option to a value similar to [', ', '].

Query

Function

function is used to search for the query results of a word.

Ajax

Object

Select the built-in AJAX query feature. This object as a shortcut has to manually write a function that performs an AJAX request. Built-in functions support more advanced features, such as throttling and disorderly reactions.

Data

Arrays/Objects

Choose to build in the query function, using arrays.

Tags

Arrays/functions

Putting Select2 into "label" mode, users can add new selections and pre-existing tags by providing this option is an array of properties or a function that returns an array of objects or strings. If strings instead of objects are used, they will have a value string that is converted to an object ID and equal to the Text property.

Containercss

Functions/Objects

The inline CSS will be added to the Select2 container. An object that contains a CSS property/value key pair or a function that returns an object.

Containercssclass

function/String

The CSS class will be added to the label of the Select2 container.

Dropdowncss

Functions/Objects

The inline CSS will be added to the Select2 drop-down container. An object that contains a CSS property/value key pair or a function that returns an object.

Dropdowncssclass

function/String

The CSS class will be added to the Select2 drop-down container.

Dropdownautowidth

Boolean

When set to true try the auto-size drop-down based on the width of the content.

Adaptcontainercssclass

Function

Filter/rename CSS classes as they are copied from the source Label Select2 Container label

Adaptdropdowncssclass

Function

Filter/Rename CSS class as they are copied from Source tab SELECT2 pull label

Escapemarkup

Function

The function is used to post-process markup from the formatter to return functionality. By default, this feature escapes HTML entities to prevent JavaScript injection.

Selectonblur

Boolean

Set to True if you want Select2 to select the current highlighting option when blurring.

Loadmorepadding

Integer

Defines how many pixels you need to load the next page before folding the following. The default value is 0, which means that the result list needs to scroll to the bottom of the next page to load the results. This option can be used to trigger faster loading and may result in a smoother user experience.

Nextsearchterm

Function

function to determine what the next search term should be

Http://select2.github.io/examples.html#tags

Jquery.select2 Fuzzy Query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.