72
rated 0 times
[
74]
[
2]
/ answers: 1 / hits: 22752
/ 12 Years ago, wed, may 30, 2012, 12:00:00
I was wondering if it is possible to bind multiple event types in backbone within a single line.
Consider the following:
var MyView = Backbone.View.extend({
id: 'foo',
events: {
'click .bar': 'doSomething',
'touchstart .bar': 'doSomething'
},
doSomething: function(e) {
console.log(e.type);
}
});
Basically what I am wondering is if it is possible to combine the event binding for 'click' and 'touchstart' into one line - along the lines of:
events: { 'click,touchstart .bar': 'doSomething' }
Any suggestions would be appreciated.
More From » backbone.js