I am trying to overwrite an event that has been inherited. I got the idea from here
However no matter what I try it will not replace the original event:
Parent View:
SD.defaultView = function(){ //Default controller for all views
//extend the view with the default home view
var HomeView = Backbone.View.extend({
el: 'body > shell',
events: { //Add click events for global clicks
'click footer saveBox': 'saveBox',
},
render: function () {
//make sure we are logged in, if we are not forward back to home page
SD.login.checkLoginState();
//Output correct tempalte
this.$el.html(templatesNeeded);
},
saveBox: function(){
//Now we have added the who reload the sex details page.
SD.pageLoad(SD.CURRENTSEX);
},
});
SD.DV = new HomeView();
SD.DV.render();
return HomeView;
}();
The child view:
//set up homeview
var whoAdd = SD.defaultView.extend({
el: 'page',
events: function(){
return _.extend({},SD.defaultView.prototype.events,{
'keyup #who': 'otherFunctions',
'click addContact': 'otherFunctions',
'click footer saveBox' : 'addWho'
});
},
template: JST['app/www/js/templates/details/whoAdd.ejs'],
addWho: function(el){
c(el);
},
render: function () {
myself = this;
this.$el.html(this.template);
$('save').addClass('disabled');
SD.setTitle('Who was involved?');
}
});
Currently saveBox
will be bound as normal. However all the examples I have seen don't initiate views quite the same way I do. I return the view from a self executing function, whilst this shouldn't cause problems I thought maybe inheritance has been messed up somewhere along the lines.