मेरी नजर में मैं this.el क्योंकि मैं इसे dinamically बनाने की घोषणा नहीं है, लेकिन इस तरह की घटनाओं को आग नहीं है।बैकबोन ताज़ा घटनाएँ देखें
देखें: 1:
App.Views_1 = Backbone.View.extend({
el: '#content',
initialize: function() {
_.bindAll(this, 'render', 'renderSingle');
},
render: function() {
this.model.each(this.renderSingle);
},
renderSingle: function(model) {
this.tmpView = new App.Views_2({model: model});
$(this.el).append(this.tmpView.render().el);
}
});
देखें 2:
App.Views_2 = Backbone.View.extend({
initialize: function() {
_.bindAll(this, 'render');
},
render: function() {
this.el = $('#template').tmpl(this.model.attributes); // jQuery template
return this;
},
events: {
'click .button' : 'test'
},
test: function() {
alert('Fire');
}
});
});
जब मैं पर क्लिक करें ".button" कुछ नहीं होता
इस कोड है। धन्यवाद;
#template संभालने '.button' के एक वर्ग के साथ एक बटन होता है, यह काम करना चाहिए। क्या आप अपने # टेम्पलेट की सामग्री पोस्ट कर सकते हैं? –