Jquery AutoComplete is a good smart reminder plug-in, but it still encounters some minor problems in actual use,
Problem 1: From webserver or common applicationsProgram(. Ashx) The program cannot automatically recognize the JSON string and is interpreted as a string. In fact, it is not very difficult to solve this problem. You only need to reload a method.CodePaste it out: Pay attention to the red part.
$ ("# TXT"). AutoComplete ("http://www.cnblogs.com/xxxx.ashx ",
{
Extraparams: {ID: ID, name: name },
Minchars: 0,
Mustmatch: True,
AutoFill: True,
Selectfirst: True,
Scrollheight: 220,
Width: 640,
Scroll: True,
Parse: function (data ){
VaR OBJ = eval ("(" + Data + ")");
VaR ROW = [];
For (VAR I = 0; I <obj. length; I ++ ){
Row [I] = {data: OBJ [I], // JSON
Value: OBJ [I]. ID, // value in the list
Result: OBJ [I]. name}; // displayed in the drop-down list
}
Return row;
},
Formatitem: function (row, I, total ){
},
Formatmatch: function (row, I, max ){
},
Formatresult: function (row, I, max ){
}
});
In this way, the problem can be solved, but a new problem occurs, that is, both the formatitem and formatmatch events are invalid, and I do not know how to solve them yet. However, if you want to perform some operations when entering the results, you can call this method. Note that this is the same as the previous $ ("# TXT "). autoComplete is written separately and written at the bottom of the binding method above.
$ ("# TXT"). Result (function (event, Data, formatted ){
});
For specific parameter meanings, refer to the official development documentation. Currently, I have used so many features that I will try again later.
Add: $ ("# TXT ").Flushcache(); The method is used to clear the autocomplete cache. Sometimes there will be cache issues after the parameter is changed.