[Resolved] How to trigger events for a button inside a form of type that is not "submit"

Hi all,

I have encounter this difficulty of not being able to trigger the button “click” event with all the ways I can think of.

The following is my html:

<form id="login-form">
     ...
    <button class="btn btn-primary" type="submit">Log In</button>
    <button class="btn btn-link" type="button" id="forgot-password">Forgot Password</button>
</form>

And my client side javascript:

Template.signupForm.events({
‘submit #signup-form’: function(event, template){

},
‘click #forgot-password’:function(){
event.preventDefault();

}
});

The submit event works fine but not the “forgot password” button. I have also tried changing the id attribute of the button to value attribute and query the value in event selector but I am getting no luck.

Does anyone know the solution to this?

Thanks in advance.

On the code you’re showing I can see that there’s no argument inside the ‘click #forgot-password’ function.

So I guess you can try:

'click #forgot-password': function(event){
  event.preventDefault();
  ...
}

Hey thank you!

I figured it out. I made a really stupid mistake of putting events in the wrong templates…

My apology and thank you for your reply