Limit results in jQuery UI Autocomplete

Here is the proper documentation for the jQueryUI widget. There isn’t a built-in parameter for limiting max results, but you can accomplish it easily: $(“#auto”).autocomplete({ source: function(request, response) { var results = $.ui.autocomplete.filter(myarray, request.term); response(results.slice(0, 10)); } }); You can supply a function to the source parameter and then call slice on the filtered array. … Read more

How to use source: function()… and AJAX in JQuery UI autocomplete

Inside your AJAX callback you need to call the response function; passing the array that contains items to display. jQuery(“input.suggest-user”).autocomplete({ source: function (request, response) { jQuery.get(“usernames.action”, { query: request.term }, function (data) { // assuming data is a JavaScript array such as // [“[email protected]”, “[email protected]”,”[email protected]”] // and not a string response(data); }); }, minLength: 3 … Read more

twitter bootstrap typeahead ajax example

Edit: typeahead is no longer bundled in Bootstrap 3. Check out: Where is the typeahead JavaScript module in Bootstrap 3 RC 1? typeahead.js As of Bootstrap 2.1.0 up to 2.3.2, you can do this: $(‘.typeahead’).typeahead({ source: function (query, process) { return $.get(‘/typeahead’, { query: query }, function (data) { return process(data.options); }); } }); To … Read more

How can I custom-format the Autocomplete plug-in results?

Yes, you can if you monkey-patch autocomplete. In the autocomplete widget included in v1.8rc3 of jQuery UI, the popup of suggestions is created in the _renderMenu function of the autocomplete widget. This function is defined like this: _renderMenu: function( ul, items ) { var self = this; $.each( items, function( index, item ) { self._renderItem( … Read more