Skip to content
This repository was archived by the owner on Mar 16, 2018. It is now read-only.

Commit 89b92fc

Browse files
committed
Merge pull request #17 from agmcleod/master
Added failure to the options hash
2 parents 9cb9d53 + 4260b5b commit 89b92fc

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

jquery.autocomplete.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ $.Autocompleter = function(input, options) {
6565
PAGEDOWN: 34,
6666
BACKSPACE: 8
6767
};
68+
69+
var globalFailure = null;
70+
if(options.failure != null && typeof options.failure == "function") {
71+
globalFailure = options.failure;
72+
}
6873

6974
// Create $ object for input element
7075
var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
@@ -388,7 +393,12 @@ $.Autocompleter = function(input, options) {
388393
} else {
389394
// if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
390395
select.emptyList();
391-
failure(term);
396+
if(globalFailure != null) {
397+
globalFailure();
398+
}
399+
else {
400+
failure(term);
401+
}
392402
}
393403
};
394404

0 commit comments

Comments
 (0)