JavaScript Using underscore.js “debounce” function with typescript using underscore debounce

The basic idea is to prevent double clicks. I'm using html <button> to call a function when clicked, which makes an ajax call. Native <button> behaviour is prevented with event.preventDefault(), that means no form should be submitted. Also, i'm using TypeScript:

private form: JQuery;
...
private getTargetAndCallAjax(): void {
    var target: string = this.form.find("form").data("target");
    this.form.find("button[type='submit']").on("click", (event)=> {
        event.preventDefault();
        this.callAjax(target);
    });
}

private callAjax(target: string): void {
    ...
}

As , i've implemented _.debounce as:

private form: JQuery;
...
private getTargetAndCallAjax(): void {
    var target: string = this.form.find("form").data("target");
    this.form.find("button[type='submit']").on("click", (event) => {
       event.preventDefault();
       var ajaxCall = function () { this.callAjax(target) };
       _.debounce(ajaxCall, 1000, true);
    });
}

private callAjax(target: string): void {
    ...
}

The goal is to call this.ajaxCall(target) every 1 second, if multiple <button> clicks detected. Unfortunately, function this.ajaxCall(target) gets never called. Any ideas?

Answer:1

In my current project I discovered a problem using websockets with socket.io and node.js on mobile devices. It seems that there is a problem for mobile deviced handling socket messages in an interval. ...

In my current project I discovered a problem using websockets with socket.io and node.js on mobile devices. It seems that there is a problem for mobile deviced handling socket messages in an interval. ...

With the following code, when shift clicking the label, why isn't the checkbox's click handler fired in FF? Both Chrome and IE11 fires it. <script> function show(event) { alert((...

With the following code, when shift clicking the label, why isn't the checkbox's click handler fired in FF? Both Chrome and IE11 fires it. <script> function show(event) { alert((...

  1. checkbox in excel
  2. checkbox symbol
  3. checkbox in word
  4. checkbox in google docs
  5. checkbox emoji
  6. checkbox in google sheets
  7. checkbox icon
  8. checkbox css
  9. checkbox image
  10. checkbox text
  11. checkbox symbol in word
  12. checkbox in html
  13. checkbox checked
  14. checkbox unicode
  15. checkbox react
  16. checkbox value
  17. checkbox alt code
  18. checkbox bootstrap
  19. checkbox input
  20. checkbox onchange

So I'm trying to create a basic angular application that parses some CSV input, and fills a table with the parsed data. You can see a plunker of what I'm trying to achieve here - http://plnkr.co/...

So I'm trying to create a basic angular application that parses some CSV input, and fills a table with the parsed data. You can see a plunker of what I'm trying to achieve here - http://plnkr.co/...

  1. javascript parser angularjs
  2. defer parsing of javascript angularjs

Requirement : Trigger a jsp page refresh when some value in the server changes. Ajax is an option, but refreshing the JSP at a particular interval will increase the load on the server. Since i am ...

Requirement : Trigger a jsp page refresh when some value in the server changes. Ajax is an option, but refreshing the JSP at a particular interval will increase the load on the server. Since i am ...

  1. trigger page refresh javascript
  2. trigger page refresh react
  3. trigger page refresh angular
  4. trigger page refresh jquery
  5. trigger page refresh
  6. trigger page refresh c#
  7. trigger page refresh asp.net
  8. trigger page refresh java
  9. js trigger page refresh
  10. php trigger page refresh
  11. ajax trigger page refresh
  12. vue trigger page refresh
  13. html trigger page refresh
  14. jsf trigger page refresh
  15. browser trigger page refresh
  16. salesforce trigger refresh page
  17. angular 6 trigger page refresh
  18. onbeforeunload trigger on page refresh