开发者

Good jQuery Autocomplete that is not part of jQuery UI?

开发者 https://www.devze.com 2023-03-11 19:26 出处:网络
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 autocomple

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 开发者_Python百科good enough for SO, it's good enough for me, forked it from agarzola on GitHub.


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.


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消