0
我想從複合視圖中單擊選擇一個元素,但是我無法讓itemView模型事件工作。Marionette modelEvents not firing
這裏是MI碼
var resultItemView = Marionette.ItemView.extend({
template: _.template('<b><%=institucionEducativaNombre%></b>'),
events: {
'click': 'onClick'
},
onClick: function (evt) {
console.log(this.model.toJSON());
this.model.set('institucionEducativaNombre', 'asdf');
console.log(this.model.toJSON());
}
});
var resultView = Marionette.CompositeView.extend({
template: _.template(''),
childView: resultItemView,
modelEvents: {
'change': 'pickSchool'
},
collectionEvents: {
'add': 'added'
},
pickSchool: function() {
console.log('This should be triggered');
console.log(evt, args);
},
added: function (evt) {
console.log('new added');
}
});
預先感謝某些部分。