Skip to content

Commit 68bd08f

Browse files
authored
fix(dropdown): show callback was ignored on remote api call
When a dropdown has given a callback for the show behavior, it was ignored when the data was retrieved by the remote api call
1 parent d10077a commit 68bd08f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/definitions/modules/dropdown.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ $.fn.dropdown = function(parameters) {
514514
;
515515
if(!module.can.show() && module.is.remote()) {
516516
module.debug('No API results retrieved, searching before show');
517-
module.queryRemote(module.get.query(), module.show);
517+
module.queryRemote(module.get.query(), module.show, [callback, preventFocus]);
518518
}
519519
if( module.can.show() && !module.is.active() ) {
520520
module.debug('Showing dropdown');
@@ -785,7 +785,10 @@ $.fn.dropdown = function(parameters) {
785785
}
786786
},
787787

788-
queryRemote: function(query, callback) {
788+
queryRemote: function(query, callback, callbackParameters) {
789+
if(!Array.isArray(callbackParameters)){
790+
callbackParameters = [callbackParameters];
791+
}
789792
var
790793
apiSettings = {
791794
errorDuration : false,
@@ -796,11 +799,11 @@ $.fn.dropdown = function(parameters) {
796799
},
797800
onError: function() {
798801
module.add.message(message.serverError);
799-
callback();
802+
callback.apply(null, callbackParameters);
800803
},
801804
onFailure: function() {
802805
module.add.message(message.serverError);
803-
callback();
806+
callback.apply(null, callbackParameters);
804807
},
805808
onSuccess : function(response) {
806809
var
@@ -817,7 +820,7 @@ $.fn.dropdown = function(parameters) {
817820
if(values.length===0 && !settings.allowAdditions) {
818821
module.add.message(message.noResults);
819822
}
820-
callback();
823+
callback.apply(null, callbackParameters);
821824
}
822825
}
823826
;

0 commit comments

Comments
 (0)