Auto Complete 5.1
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.
For those upgrading from 4.1, check out the
changelog, the
backwardsCompatible setting, and the
4.1-compatible page showing that upgrading works.
A list of commonly misspelled words in English found at
http://www.esldesk.com/esl-quizzes/misspelled-words/misspelled-words.htm
is used as the sample result set.
Currently in Focus:
Previously in Focus:
+ Open Code
var $div = $('#AutoCompleteFocus');
$.autoComplete.focus = function(){
var focus = $.autoComplete.getFocus( true ), previous = $.autoComplete.getPrevious( true );
$div.find('.current span').html(
focus.length ? 'name=' + focus.attr('name') + "'" : 'Nothing in Focus'
);
$div.find('.previous span').html(
previous.length ? 'name=' + previous.attr('name') + "'" : 'Nothing previously in focus'
);
};
/**
* 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.