the jquery UI team has a blog on how to replace the legacy autocomplete and justifies that it can replicate all of the old features and options. Based on my testing, i dont think they can replicate:
i see this questions on how to replicate some of the legacy autocomplete options from this plugin, and there is a selected answer but it doesn't address these situations.
The jquery ui folks have an example of replicating selectFirst in the new autocomplete, but unless i am mistaken, it only works with local data source (not remote data source as the menu is usally not filled out before the event get called).
am i missing something or are these scenarios simply not supported in jquery ui autocomplete ??
Autocomplete mechanism is frequently used in modern websites to provide the users a list of suggestion while typing the beginning word in the text box. It facilitates the user to select an item from the list, which will be displayed in the input field.
To enable an autocomplete in jQuery UI, we will be using the enable() method. jQuery UI enable() method is used to enable the autocomplete.
jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. Whether you're building highly interactive web applications or you just need to add a date picker to a form control, jQuery UI is the perfect choice.
These scenarios are supported actually, but you have to extend ui.autocomplete widget to achieve desired behavior. Quick example to implement selectFirst feature:
$.widget( "ui.autocomplete2", $.ui.autocomplete, {
_renderMenu: function( ul, items ) {
var self = this;
$.each( items, function( index, item ) {
self._renderItem( ul, item );
});
// setTimeout is needed because jQueryUI automaticaly removes
// active item just after menu rendering
setTimeout( function(){
self.menu.activate(
// fake event object. Needed to avoid jQueryUI error
// (unsafe property access)
{'type':'fake'},
ul.find(':first') );
}, 1);
}
});
Attention: Always check if new widget is still compatible with new version jQuery UI!
Update: sample mustMatch implementation han be found here: http://jqueryui.com/demos/autocomplete/combobox.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With