Home > Software engineering >  How to apply debouncer on change function jQuery?
How to apply debouncer on change function jQuery?

Time:03-19

How would one apply debouncer on this jQuery function. So far it makes no call.

 $('.make-ajax-call-js').on($.debounce('change', function (e) {
//whatever ajax call
}));

I have debouncer script included in my js files.

CodePudding user response:

Try like this:

$('.make-ajax-call-js').change($.debounce(1000, function(e) {
    console.log("It works!");
}));

CodePudding user response:

To fix this, you will have to pass in the debouncing function as a parameter to the jquery click event along with the debounce time

$('.make-ajax-call-js').click($.debounce(250, function(e) {
    //whatever ajax call
}));
  • Related