最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Good jQuery Autocomplete that is not part of jQuery UI? - Stack Overflow

programmeradmin3浏览0评论

Is there a good alternative to jQuery UI autocomplete?

I couldn't find one on the internet. jQuery UI is far too big for just using the autocomplete, and I don't want to roll yet another autocomplete on my own.

Answer: jQuery UI custom build for just autocomplete is 23,052 bytes. SO uses the original Zaefferer version that was adapted into jQuery UI autocomplete. I guess if it's good enough for SO, it's good enough for me, forked it from agarzola on GitHub.

Is there a good alternative to jQuery UI autocomplete?

I couldn't find one on the internet. jQuery UI is far too big for just using the autocomplete, and I don't want to roll yet another autocomplete on my own.

Answer: jQuery UI custom build for just autocomplete is 23,052 bytes. SO uses the original Zaefferer version that was adapted into jQuery UI autocomplete. I guess if it's good enough for SO, it's good enough for me, forked it from agarzola on GitHub.

Share Improve this question edited Jun 7, 2011 at 13:43 CamelCamelCamel asked Jun 7, 2011 at 13:12 CamelCamelCamelCamelCamelCamel 5,2008 gold badges63 silver badges94 bronze badges 4
  • 1 Possible duplicate: stackoverflow.com/questions/188442/…. At least the (some of the) same answers will be given even though the actual question is a bit different. – Aleksi Yrttiaho Commented Jun 7, 2011 at 13:16
  • How big was the minified custom build? – Andrew Jackman Commented Jun 7, 2011 at 13:16
  • I agree with @Aleksi - it's 20kb after a custom build – Mike Robinson Commented Jun 7, 2011 at 13:17
  • 1 I would list your edit as an answer. Zaefferer's plugin is 14,157 bytes, which bests jQuery UI (20,231 bytes) by 30% in terms of size. – Chris Shouts Commented Jun 7, 2011 at 13:36
Add a comment  | 

7 Answers 7

Reset to default 6

You can download a customized version of jQuery UI with just the components you need from http://jqueryui.com/download. Click Deselect all components then click the checkbox next to Autocomplete. The resulting minified js file is 20 KB uncompressed.

A Google search for 'jquery autocomplete' produced this DevBridge one (and all the others):

http://www.devbridge.com/projects/autocomplete/jquery/

This is also the most highly upvoted non-accepted answer in the possible duplicate of this question.

The jQuery official plugin :

http://docs.jquery.com/Plugins/autocomplete

Select2 jQuery plugin that turn select into autocomplete input+list :

http://ivaynberg.github.io/select2/

Chosen jQuery plugin, same thing but from a different author :

http://harvesthq.github.io/chosen/

Jörn Zaefferer jQuery plugin :

http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

Yahoo YUI :

http://developer.yahoo.com/yui/autocomplete/

Selectize.js (jQuery-based) :

https://selectize.github.io/selectize.js/

Twitter Typeahead :

https://twitter.github.io/typeahead.js/

See https://github.com/agarzola/jQueryAutocompletePlugin/blob/master/jquery.autocomplete.js

You can download a custom version of jQuery UI that only includes the autocomplete module: http://jqueryui.com/download

3 year old question this but since it comes 2nd on Google results for "best jquery-ui autocomplete alternative" I believe it's worth placing a link here for twitter's Typeahead implementation: http://twitter.github.io/typeahead.js/

Slightly annoying that you might need the Hogan templating engine to make it work (adding a few more kb's to the load), but if you invest the time to read the docs it will be worth it.

I replaced my "location lookup" jquery UI implementation after 30 mins of perusing the docs with the (simplified) code structure below:

$('.location_text_field').typeahead({

    name : 'locations',
    remote : {
        url : "/get_locations.php",
        filter : function (response) {
            return response.locations;
        }
    },
    template : '<p>{{{label}}}</p>',
    engine : Hogan

}).on({

    // When the user selects a location do something clever
    'typeahead:selected' : function (e, datum) {
       // Doing something clever here....
    },

    // Reset the cleverness above if the user changed
    // the text of the field manually on his own
    'keyup' : function () {
         // Reset cleverness
    }

});

... and it works like a charm.

I was just looking for an alternative myself and found this

https://github.com/onigoetz/jquery.autocomplete

It uses jQuery, but not jQuery UI. It is size conscious, and it compatible with jQuery UI. Its "forked from agarzola/jQueryAutocompletePlugin" on github.

It may not have the backing of the well known jQuery UI implementation, but I tested it, and right now it seems to be everything advertised.

发布评论

评论列表(0)

  1. 暂无评论