Auto Complete 5.0
Auto Complete sends input from a user to a script server side, and creates a drop down with the
JSON data returned. It supports the
metadata plugin,
as well as script level caching. A few examples are included on this page, but check out the
docs
for a full list of features.
Currently in Focus:
Previously in Focus:
+ Open Code
var $div = $('#AutoCompleteFocus');
$('input[type=text]').focus(function(){
var f = $.autoComplete.getFocus(), p = $.autoComplete.getPrevious();
$div.find('.current span').html('#' + $.autoComplete.focus + ": '" + $(f).attr('name') + "'");
$div.find('.previous span').html('#' + $.autoComplete.previous + ": '" + $(p).attr('name') + "'");
});
/**
* Button code for above example
*/
// Add enabling feature (disable to begin with)
$('input[name=enable-1]').attr('disabled', 'true').click(function(){
$('input[name=search1]').autoComplete();
$('input[name=destroy-1]').attr('disabled', false);
$(this).attr('disabled', 'true');
});
// Add disabling feature
$('input[name=destroy-1]').click(function(){
$('input[name=search1]').autoComplete('destroy');
$('input[name=enable-1]').attr('disabled', false);
$(this).attr('disabled', 'true');
});
Prevent form submission when running callbacks on selection
// Auto-complete preventing form submission, and firing onSelect function
$('input[name=search2]').autoComplete({
// preventEnterSubmit is already flagged true by default
onSelect: function(event, ui){
alert('You have selected ' + ui.data.value);
}
});
Be sure to check out the
docs for a full list of options.