例如我有:
Job.Views.Response = Backbone.View.extend({
el: '.ra-response-button',
events: {
"click" : "alert"
},
alert: function() {
console.log(this.$el);
};
)};
我有多个按钮(按钮)。我希望只有单击按钮才能工作。我怎么能这样做?
例如我有:
Job.Views.Response = Backbone.View.extend({
el: '.ra-response-button',
events: {
"click" : "alert"
},
alert: function() {
console.log(this.$el);
};
)};
我有多个按钮(按钮)。我希望只有单击按钮才能工作。我怎么能这样做?
将 更改为el
按钮的父元素,然后执行以下操作
<div id="buttonWrapper">
<input type="button" id="button1" />
... snip ...
</div>
看法:
Job.Views.Response = Backbone.View.extend({
el: 'buttonWrapper',
events: {
'click #button1': 'eventHandler1',
'click #button2': 'eventHandler2',
... And so on...
}