Yes, it can be done . To stop the search, of course, the minimum length for the search term is increased to (arbitrary) 1000 characters. At the same time, the search was automatically programmed into . Click () an event is tied to a button - this is documented on the Events tab on this page . The minimum length is set to 0 (so the search really works) before starting the search, and after the completion of autocompletion, it returns to 1000.
HTML:
<label for="tags">Tags: </label>
<input id="tags" />
<input type="button" value="Search"/>
JavaScript:
var availableTags = [
'ActionScript',
'AppleScript',
'Asp',
'BASIC',
'C',
'C++',
'Clojure',
'COBOL',
'ColdFusion',
'Erlang',
'Fortran',
'Groovy',
'Haskell',
'Java',
'JavaScript',
'Lisp',
'Perl',
'PHP',
'Python',
'Ruby',
'Scala',
'Scheme'
];
$('#tags').autocomplete({
source: availableTags,
minLength: 1000,
close: function(event, ui) {
$('#tags').autocomplete('option', 'minLength', 1000);
}
});
$('input[type="button"]').click(function() {
$('#tags').autocomplete('option', 'minLength', 0);
$('#tags').autocomplete('search', $('#tags').val());
});
andyb source
share