JS control autocomplete 0.11 demo and download updated on January 1, January 5

Source: Internet
Author: User

Updated on January 1, January 5

Fixed the bug where the focus of the automatically completed text box is missing and the container cannot disappear automatically.
Added the expandAllItem method. All items can be displayed when you double-click it. For details, see the example.
Added the customStyle example to demonstrate how to beautify the autocomplete control. For details, see the autocomplete_custom css file.

Demo and download:
Http://www.never-online.net/code/neverModules/autocomplete/

Compared with the previous version, the following functions are available:
1. The matching speed is improved.
2. Add the ignoreCase attribute. (if it is false, it is case sensitive. The default value is true)
3. Add the ignoreWhere attribute (if it is true, greedy match will be used for the matching result, that is, the dataSource content will be sent to the matching result as long as there are input characters in the entire string)
4. Press esc to return.
5. Compatible with IE6.0, Opera9.0, Mozilla Firefox1.5
6. You can manually clear dataSource data or assign a value to dataSource dynamically. For more information about AJAX, see the example.
7. The highlighted attribute (the default value is true. It is recommended to set it to false when there is a large amount of data ).
8. In IE, make up that the div is blocked by the select Control. For details, see the first example.
9. Direction keys are supported.

Ideas and references:

During initialization, I use join ("") to generate a dataSource string (the html used in string words is as short as possible, to generate data with the least number of strings), and then use regular expressions for matching. It seems that the speed is very fast.

Although the range function has not been added, it is enough. The speed is still ideal. The speed problem is that if you want to make full use of the efficiency of the kernel in Opera, Mozilla, and IE, the result may be that the Code may be greatly extended. After all, the efficiency varies greatly between different kernels.

Compatibility and efficiency are also a conflict. Using insertAdjanceHTML is one of the simple compatibility methods for inserting a string in the case of a large number.

Another problem is to add highlight. After using join, to highlight, you must trace back again, which is equivalent to matching twice. This is also one of the efficiency issues. Therefore, we recommend that you set the highlighted attribute to false when the data volume is large. In theory, this efficiency should increase by about 40%.

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.