buttonbackbone.js

Activate-Deactivate submit button in a form


I made a registration form using backbone.js, CoffeeScript and jquery.
I am trying to disable the submit button after 1 click (so that it doesn't fire events again and again) , i also want that button get active again when i fill fields of my form.. Thanks for your time.


Solution

  • In your code that runs the event (hopefully in the events delegate routine of your view) all you have to do is tell JQuery to disable the button

    $("#btnSubmit").attr("disabled", true);
    

    Then when you need to re-enable it

    $("#btnSubmit").removeAttr("disabled");
    

    Just call the appropriate calls when required.