Don't fall over if a model doesn't have actions defined
It appears that one notification stealing focus from another causes some weirdness: both clicking on a button on one view triggers the event on both views (the original and the new view that stole the div). As long as the first view does *not* define any click events, everything is fine -- this is the case for the saving notification. I'll worry about the reason for this later; it has something to do with views listening to models even after they no longer should be.
This commit is contained in:
@@ -24,16 +24,19 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
|
||||
this.model.hide();
|
||||
},
|
||||
primaryClick: function() {
|
||||
var primary = this.model.get("actions").primary;
|
||||
var actions = this.model.get("actions");
|
||||
if(!actions) { return; }
|
||||
var primary = actions.primary;
|
||||
if(!primary) { return; }
|
||||
if(primary.click) {
|
||||
primary.click.call(this.model);
|
||||
}
|
||||
},
|
||||
secondaryClick: function(e) {
|
||||
var secondaryList = this.model.get("actions").secondary;
|
||||
if(!secondaryList) {
|
||||
return;
|
||||
}
|
||||
var actions = this.model.get("actions");
|
||||
if(!actions) { return; }
|
||||
var secondaryList = actions.secondary;
|
||||
if(!secondaryList) { return; }
|
||||
// which secondary action was clicked?
|
||||
var i = _.indexOf(this.$(".action-secondary"), e.target);
|
||||
var secondary = this.model.get("actions").secondary[i];
|
||||
|
||||
Reference in New Issue
Block a user