However, the only pity is that when the Chinese Input Method is enabled, firefox3.0 automatically matches Chinese pinyin, And the entered Chinese cannot be triggered in time; in my IE6.0, there is no such problem.
Cause analysis:
The Autocomplete plug-in triggers automatic matching of user input characters through the "keydown" event (Analysis of jquery. autocomplete. js line 92nd). in IE6, when the input method is enabled, the input character does not trigger the "keydown". It is triggered only after the Chinese input is complete, therefore, there is no difference between Chinese Input and latin. However, in firefox3.0, no matter whether the input method is enabled or not, the "keydown" event is triggered by pressing the key. Therefore, the Chinese input is complete, the system automatically matches some Chinese pinyin letters. ------ So there is only a problem with Firefox.
Solution:
The most common method found on the Internet is to modify jquery. autocomplete. line 3 of js will replace "keydown" with "keyup", but this is not the fundamental method. After this change, you can automatically match the entered Chinese in firefox in a timely manner, however, the important event mechanisms such as carriage return and tab in the original plug-in are damaged. For example, if your input is in a form, press enter to directly submit the form from the original input to input. This is not what we want.
My method principle is to add an event that the original plug-in triggers the query, that is, when the character in the input column changes, re-query (call its internal onChange function ), this is mainly for firefox, because the most accessed systems are IE and firefox. In firefox, an input change event is oninput, so we only need to insert the following code in line 199th of the original jquery. autocomplete. js:
Copy codeThe Code is as follows:
. Bind ("input", function (){
// @ Hack: support for inputing chinese characters in firefox
OnChange (0, true );
});
After insertion, the code is roughly as follows:
Copy codeThe Code is as follows:
...
...
JQueryinput. unbind ();
JQuery (input. form). unbind (". autocomplete ");
}). Bind ("input", function (){
// @ Hack: support for inputing chinese characters in firefox
OnChange (0, true );
});
...