Skip to content

Commit 04559bc

Browse files
feat(dropdown): onSearch callback
This PR adds a new onSearch callback to allow access to the search term being entered so that external processes can be informed about the term being typed in. Such processes may include an API that requires authentication with a token, especially if the website in question already has an existing API
1 parent ba420fe commit 04559bc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/definitions/modules/dropdown.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ $.fn.dropdown = function(parameters) {
297297
: module.get.query()
298298
;
299299
module.verbose('Searching for query', query);
300-
if(module.has.minCharacters(query)) {
300+
if(settings.fireOnInit === false && module.is.initialLoad()) {
301+
module.verbose('Skipping callback on initial load', settings.onSearch);
302+
} else if(module.has.minCharacters(query) && settings.onSearch.call(element, query) !== false) {
301303
module.filter(query);
302304
}
303305
else {
@@ -4038,6 +4040,7 @@ $.fn.dropdown.settings = {
40384040
onChange : function(value, text, $selected){},
40394041
onAdd : function(value, text, $selected){},
40404042
onRemove : function(value, text, $selected){},
4043+
onSearch : function(searchTerm){},
40414044

40424045
onLabelSelect : function($selectedLabels){},
40434046
onLabelCreate : function(value, text) { return $(this); },

0 commit comments

Comments
 (0)