bind function not working in javascript

This is the html I am using

  <div class="col-md-12 col-sm-12 text-center permissions-submit">
          <button class="btn btn-primary ">Set Permissions</button>
 </div>
//remove extra ending div

Now I have written a method named bindEvents which would do the following

 bindEvents : function(){
        this.$elSubmit = $('.permissions-submit');
        this.$elSubmitButton = this.$elSubmit.find('button');
        console.log('submit',this.$elSubmitButton);
        this.$elSubmitButton.on('click',this.permissionsSubmit.bind(this));
    }

The issue is that,nothing happens on the button click. It is supposed to call the method "permissionsSubmit".

Answers 1

  • why don't you try this as it's mentioned on jQuery API.

     $( "#foo" ).bind( "click", function() {
            //Do your work here
      });
    

Related Articles