Created
March 5, 2014 23:28
-
-
Save cafuego/9378959 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
/** | |
* Keep an unmodified copy of the core search callback function. | |
*/ | |
Drupal.ACDB.prototype.coreSearch = Drupal.ACDB.prototype.search; | |
/** | |
* Override the search callback. | |
* | |
* Prevent autocomplete search from running if the search string is shorter | |
* than the limit. Otherwise, call the clone of the original search callback. | |
*/ | |
Drupal.ACDB.prototype.search = function (searchString) { | |
var limit = Drupal.settings.autocomplete_limit['limit']; | |
// Do not search if the string is too short. | |
if (limit && searchString.length < limit) { | |
return; | |
} | |
// Call the original core search callback. | |
return this.coreSearch(searchString); | |
}; | |
// Good night, and good luck. | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment