Commit 69a6ec0c by David Baumgold

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.
parent 13337178
......@@ -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];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment