Jquery Autocomplete combined with asp.net usage highlights

Source: Internet
Author: User

Problem 1: When a json string is obtained from a webserver or a general application processing program (. ashx), it cannot be automatically identified and is interpreted as a string type. In fact, it is not very difficult to solve this problem. You only need to reload a method. Below we will post some code: Pay attention to the red part.
Copy codeThe Code is as follows:
$ ("# Txt"). autocomplete ("/Asmx/ExecutePlan. ashx ",{
ExtraParams: {hosid: HosID, profid: ProfID },
MinChars: 0,
Max: 700,
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]. instName, // value in the list
Result: obj [I]. instName}; // It is displayed in the drop-down list.
}
If (obj. length = 1)
{
// $ ("# HfInstID" 2.16.val(obj1_02.16.exe cuteID );
// $ ("# Button1"). click ();
}
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.

Related Article

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.