Reputation: 1377
I have this form write in ember using bootstrap framework. I want when keypress enter to catch the primary button, but the action cancel triggered.
<form {{action 'create' on="submit"}} class="form-horizontal form-bordered formaddObject">
<div class="form-group">
<div class="leftColCampaignType">
<label class="col-sm-3 control-label labelFormCampaign addObject">Campaign's name</label>
</div>
<div class="rightColCampaignType">
{{input value=campaign_name id="campaign_name" placeholder="Enter Name" class="form-control"}}
<div class="transitionbuttonsinCampsettings transitionbuttonsinAddObject">
<button class="btn btn-default"{{action 'cancel'}} style="background-color: #E2E2E2;">Cancel</button>
<button class="btn btn-primary" type="submit" style="background-color:#ffa019!important; border:none;">Submit</button>
</div>
</div>
</div>
</form>
Upvotes: 2
Views: 482
Reputation: 1058
If you add a type="button"
to your Cancel button it is not going to trigger form submission when pressing enter.
So your Cancel button look something like:
<button type="button" class="btn btn-default"{{action 'cancel'}} style="background-color: #E2E2E2;">Cancel</button>
Here's a full working example, check out the console logs coming from the route actions: http://emberjs.jsbin.com/pipivibedo/1/edit?html,js,console,output
Upvotes: 1