I have a list of commands, and in a command - a list of tasks. JSON data is as follows:
{ {"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" } } } }
My views:
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'));
Somewhere in another view, I fire the following event: I need to delete task 93558. App.vent.trigger ("Scheduling: Task: delete: 93558");
I expect this to happen:
'Removed task 93558'
"Command: task deleted: 32"
But what he sees:
'Removed task 93558'
"Team: task deleted: 48"
It seems that the itemView event bubble does not bubble in the desired CollectionView.
Please can someone shed some light on this for me.