我有一个带有主干视图的基本表单,当我在顶部输入上按 enter 时,会触发 open 事件。如何确保打开事件仅在我按下浏览按钮时触发?
<form method="post">
<div>
<input type="text" />
</div>
<div id="myId">
<input type="text" />
<button class="browse">Browse...</button>
</div>
<input type="submit" value="Save" />
</form>
var MyView = Backbone.View.extend({
events: {
'click button.browse': 'open'
},
open: function(e) {
alert('Open dialog');
},
initialize: function() {},
render: function() {}
});
$(function() {
var myView= new MyView({ el: $('#myId') });
});