How to listen to the submit event of a form in a meteorjs template?

Viewed 7174

If I have a template like this

<template name="my_form">
  <form name="my_form">
    <input name=" ....
  </form>
</template>

I'd like to listen to the submit event of "my_form".

I tried this:

Template.my_form.events({
  'submit form': function( event ){   // also tried just 'submit'
    console.log( 'Submitting form!' );
    event.preventDefault();
    event.stopPropagation();
    return false; 
  }
});

But no luck. It appears the event handler doesn't get registered. Is there something I'm missing?

p.s. I am aware that I can handle a form "submission" by listening to the submit button click event, but I need to use the form submit event in this specific scenario.

3 Answers
Related