'Backbonejs events syntax on objects
Suppose that I have the following view:
var SampleView = Backbone.View.extend({
initialize: function() {
this.child_element = this.$('#new-catalog>button:first');
},
events: {
'click #new-catalog>button:first': function() { alert('clicked'); },
},
el: '#some-element',
});
If you have some non trivial selection for custom children items (like my child_element selected with #new-catalog>button:first, is it possible to avoid redefining it in the events property and instead refer to this.child_element?
Of course I can do this.child_element.on('click', ..., but I'd like to use the provided events dictionary.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
