From 69a6ec0c97e8ab8d97f759494971b377c8e539ce Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Fri, 10 May 2013 16:50:37 -0400 Subject: [PATCH] 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. --- cms/static/js/views/feedback.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cms/static/js/views/feedback.js b/cms/static/js/views/feedback.js index 70100f53bd..a6cf48b33f 100644 --- a/cms/static/js/views/feedback.js +++ b/cms/static/js/views/feedback.js @@ -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];