我尝试用keydown(enter)提交一个表单,并通过我想要的函数发送它。但是当我按回车键时,它显示的行为就像HTML按钮的类型是submit一样。下面是我的BackboneJS代码:
$view.UserProfile_ConfirmPhoneNumber = Backbone.View.extend({
el: "#confirmPhoneNumberForm",
events: {
"click #send-confirm-phone-number-code": "sendConfirmPhoneNumberCode",
'keydown': 'keyAction',
},
keyAction: function (e) {
var code = e.keyCode || e.which;
if (code == 13) {
sendConfirmPhoneNumberCode();
}
},
sendConfirmPhoneNumberCode: function() {
//some code
}
下面是我的html:
<form class="newRegister-formBox basketForm" id="confirmPhoneNumberForm" autocomplete="off">
<input type="hidden" id="returnUrl" value="@ViewBag.ReturnUrl" name="ReturnUrl">
<div class="newRegister-formBox">
<div class="formElement newRegister-input">
<i class="fa fa-key loginIcone"></i>
<input autocomplete="off" type="text" name="code" id="code" class="form-control persianDigitInput" placeholder="enter code">
</div>
<div class="newRegister-button">
<button type="button" id="send-confirm-phone-number-code" class="animateBtn greenAnimateBtn">
<i class="fa fa-check"></i>
confirm
</button>
</div>
</div>
</form>
1条答案
按热度按时间krcsximq1#
尝试