チームのリストがあり、チームにはタスクのリストがあります。JSON データは次のようになります。
{
{"teamId":38,
"teamName":"Analytics",
"tasks":{
{
"taskId":93561,
"taskName":"Analytics Country Report"
}
}
},
{"teamId":32,
"teamName":"Client Service - Team Beaumont",
"tasks":{
{
"taskId":93558,
"taskName":"Project Management"
}
}
},
{"teamId":34,
"teamName":"Copy",
"tasks":{
{
"taskId":93580,
"taskName":"Copy"
}
}
},
{"teamId":48,
"teamName":"Engineering - Team LZ",
"tasks":{
{
"taskId":93573,
"Front-end Development"
},
{
"taskId":93562,
"taskName":"Quality Control"
}
}
}
}
私の見解:
View.SchedulingTask = Backbone.Marionette.ItemView.extend({
template: 'resource-planning/scheduling/templates/_scheduling-task',
className: 'scheduling-task-handle',
initialize: function() {
var _this = this;
App.vent.on( "scheduling:task:remove:" + _this.model.get('taskId'), function(){
console.log('Task removed' + _this.model.get('taskId');
_this.trigger('task:remove');
_this.remove();
})
},
});
View.SchedulingTeam = Backbone.Marionette.CompositeView.extend({
template: 'resource-planning/scheduling/templates/_scheduling-team',
itemView: View.SchedulingTask,
initialize: function(){
this.collection = _this.model.get('tasks');
this.on('itemview:task:remove', function(itemView){
console.log("Team: task removed: " + _this.model.get('teamId'));
// If the collection is empty, I need to remove the team as well
});
}
});
別のビューのどこかで、次のイベントをトリガーします: タスク 93558 を削除します。 App.vent.trigger("スケジューリング:タスク:削除:93558");
私が期待しているのは、次のことです。
「タスクが削除されました 93558」
「チーム: 削除されたタスク: 32」
しかし、見られるのは次のとおりです。
「タスクが削除されました 93558」
「チーム: 削除されたタスク: 48」
itemView イベントのバブリングが正しい CollectionView にバブリングしていないようです。
誰かが私のためにこれに光を当てることができます.