我在视图中有一个表单。如何以及在哪里可以处理表单提交事件?另外,我在哪里可以编写代码来处理此表单中存在的元素的事件。我尝试在以下位置处理它:
//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>
当我单击按钮上的任意位置时,只会触发单击事件。如何访问提交事件?