I have a form inside a View. How and where can I handle the form submit event? Also where can I write the code for handling events on elements present in this form. I tried handling it at:
//Instantiating a view with a template name signup
var signup = Ember.View.create({
templateName: "signup",
name: 'Sign Up',
click: function()
{
alert('click triggered from signup template');
},
submit: function()
{
alert('submit triggered');
},
signup: function()
{
alert('signup triggered');
}
});
<script type="text/x-handlebars" data-template-name="signup">
<form class="form-horizontal" {{action "signup" on="submit"}}>
<br/>
<div align="center" >
<table class="table-hover>
<tr>
<td>
<label>First Name</label>
</td>
<td>
{{input value=firstName class="controls" type="text"}}
</td>
</tr>
<tr>
<td>
<label>Last Name</label>
</td>
<td>
{{input value=lastName class="controls" type="text"}}
</td>
</tr>
<button class="btn btn-primary " type="submit" >Register</button>
</div>
</form>
</script>
When I click anywhere on the button, only click event is triggered. How do I get access to the submit event?