I'm using my App.vent object to handle some back n forth between my Controller and my LayoutView. My LayoutView contains this:
events:{
'click @ui.addQuestion': 'addQuestion'
},
addQuestion: function(e){
var newModel = new App.ActivitySetupModule.Entities.Question();
App.vent.trigger('activity:questions:add:question', newModel)
}
This LayoutView gets swapped in and out of the 'mainRegion" region of my app like so in the Controller:
this.activityLayoutView.mainContentRegion.show(this.LayoutView);
And also in the Controller is Vent listening:
App.vent.on('activity:questions:add:question', function(model){
// ajax call
}
The problem is that everytime I swap out LayoutView to go to a new section, the ajax call gets called for everytime i swapped it out when I click on the addQuestion button. So if i came to this page 3 times where the Layout view was shown, then it will make the ajax call 3 times. But if i put a console.log in the addQuestion function, it will only ever display ONCE. So I don't get that. Is this a case of a zombie view? I have reasons for not binding and listening to the layout view object so I am hoping to use vent here.
addQuestion
is only called once, though?! That's odd. If it was a zombie view, the function would get called multiple times. Is there anything else in the app triggering this event? – Cory DanielsonApp.vent.on('activity:...
) must be getting called multiple times as well, and the event is not being unbound. That would result in the problem that you're having.... How/when is that last code snippit from the Controller called? – Cory Danielson