eric
eric

Reputation: 4951

Prevent page reload on form Button click in meteor?

Not sure whether this is a Meteor problem, JavaScript problem, or otherwise. Clicking on a form button causes an undesired page reload.

Other info:

Upvotes: 7

Views: 7223

Answers (2)

kynan
kynan

Reputation: 13613

Other than returning false you can also call preventDefault() on the event passed into your handler:

'click #submit' : function (template, event) {
  ...
  event.preventDefault();
}

This will only prevent the default action (i.e. submitting the form), but will not stop the event from propagating.

Upvotes: 5

I think you have to return false at the end of your function for prevent submit.

Upvotes: 13

Related Questions