jquery Mutilselect plugin add Chinese and English auto-complete

Source: Internet
Author: User

jquery Mutilselect is automatically prompted by default only based on the option set

function (key, value) {            $ (' #channels ')             . Append ($ ("<option></option>")             . attr ("Value", value)             // by default by the value of text in the move prompt     }    );

Read the following requirements:

There are a few options:

Beijing

Tianjin

Hubei

When inputting Chinese, the control can automatically prompt according to input Chinese, such as input "north" hint Beijing, but if want to enter "bei" Prompt "Beijing". The control cannot complete this function, this time need to modify the source code, In the Jquery.multiselect.filter.js file, there is a function updatecache that is specifically prompted to find the definition of this function

Updatecache:function() {      //Each list item       This. rows = This. Instance.menu.find (". Ui-multiselect-checkboxes li:not (. Ui-multiselect-optgroup-label)"); //Cache       This. cache = This. Element.children (). Map (function() {        varElem = $ ( This); //Account for optgroups        if( This. tagname.tolowercase () = = = "Optgroup") {Elem=Elem.children (); }        returnElem.map (function() {          return  This. Innerhtml.tolowercase ();      }). get ();    }). get (); //The following section of code is custom, adding phonetic hints feature      if( This. cache.length>0){           for(vari=0;i< This. cache.length;i++){              varTV = This. Cache[i]; varletter=tv+CITYMAP[TV]; if(letter!=undefined) {                   This. cache[i]=tv+Letter ; }          }      }    },

The code above is the new code. The new code is just a few lines. As follows

// The following section of code is custom, adding phonetic hints feature      if (this. cache.length>0) {          for (var. cache.length;i++) {               var  This . Cache[i];               var letter=tv+Citymap[tv];               if (letter!=undefined) {                  this. cache[i]=tv+ letter;       }}

Explain this code:

  This.rows represents an optional item for each line

  This.cache is an array that initializes all option text to this array by default, and after the user enters the character, it iterates through the array, matching the regular expression, and the elements on the match are automatically displayed on the front end.

Full Source code Download:

Link: http://pan.baidu.com/s/1c0AdgI0 Password: 6lck

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.