Jquery.autocomplete support Chinese input (Firefox) Correction method _jquery

Source: Internet
Author: User
But the only regret is that when the Chinese input method is opened, the firefox3.0 is the automatic matching of Chinese pinyin, and the Chinese can not trigger the match in time, but under my IE6.0, there is no such problem.

Reason Analysis:
AutoComplete plug-in automatic matching of user input characters is done through the "KeyDown" event (parse Jquery.autocomplete.js line 92nd), in IE6, when the input method is opened, the characters entered will not trigger "KeyDown" , only after the Chinese input has been triggered, so Chinese input and Latin text no difference, but in firefox3.0, regardless of input method open No, the key will trigger the "KeyDown" event, so that the completion of Chinese input, automatic matching is just played part of the Chinese pinyin. ------So only Firefox has a problem.

Workaround:
Online most of the practice is to modify the Jquery.autocomplete.js 92nd line, the "KeyDown" replaced by "KeyUp", but this is not the fundamental approach, although this can be changed in Firefox in time for the input of the Chinese to automatically match, but the original plug-in in return, tab and other important event mechanisms, such as change, if your input is in a form, carriage return from the original selected items into the input into the direct Submission Form form, this is not what we want.

The principle of my method is to add an original plug-in trigger query event, when the input column occurs when characters change, requery (call its internal onchange function), here mainly for Firefox, because our system access to the most is IE and Firefox. And exactly Firefox has an input change event is oninput, then we just in the original jquery.autocomplete.js line 199th, insert The following code:
. Bind ("Input", function () {
@hack: Support for inputing Chinese characters in Firefox
OnChange (0, true);
});


after inserting, the code is probably as follows:

...
...
Jqueryinput.unbind ();
JQuery (Input.form). Unbind (". AutoComplete");
}. Bind ("Input", function () {
@hack: Support for inputing Chinese characters in Firefox
OnChange (0, true);
});
...

2, support multiple return selected:
Modify 91 lines:
Only opera doesn ' t trigger KeyDown multiple The times while pressed, others don ' t work with keypress in all
$input. Bind ($.browser.opera? "KeyPress": "KeyDown") + ". AutoComplete", function (event) {
Modified to:
Only opera Mozilla doesn ' t trigger KeyDown multiple The times while pressed, others don ' t work with keypress in all
$input. Bind (($.browser.opera | | $.browser.mozilla)? "KeyPress": "KeyDown") + ". AutoComplete", function (event) {

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.