Commit 13337178 by David Baumgold

Message action callbacks have model set to `this`

parent f5f7cf70
...@@ -13,19 +13,20 @@ CMS.Models.SystemFeedback = Backbone.Model.extend({ ...@@ -13,19 +13,20 @@ CMS.Models.SystemFeedback = Backbone.Model.extend({
"primary": { "primary": {
"text": "Save", "text": "Save",
"class": "action-save", "class": "action-save",
"click": function(model) { "click": function() {
// do something when Save is clicked // do something when Save is clicked
// `this` refers to the model
} }
}, },
"secondary": [ "secondary": [
{ {
"text": "Cancel", "text": "Cancel",
"class": "action-cancel", "class": "action-cancel",
"click": function(model) {} "click": function() {}
}, { }, {
"text": "Discard Changes", "text": "Discard Changes",
"class": "action-discard", "class": "action-discard",
"click": function(model) {} "click": function() {}
} }
] ]
} }
......
...@@ -26,7 +26,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({ ...@@ -26,7 +26,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
primaryClick: function() { primaryClick: function() {
var primary = this.model.get("actions").primary; var primary = this.model.get("actions").primary;
if(primary.click) { if(primary.click) {
primary.click(this.model); primary.click.call(this.model);
} }
}, },
secondaryClick: function(e) { secondaryClick: function(e) {
...@@ -38,7 +38,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({ ...@@ -38,7 +38,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
var i = _.indexOf(this.$(".action-secondary"), e.target); var i = _.indexOf(this.$(".action-secondary"), e.target);
var secondary = this.model.get("actions").secondary[i]; var secondary = this.model.get("actions").secondary[i];
if(secondary.click) { if(secondary.click) {
secondary.click(this.model); secondary.click.call(this.model);
} }
} }
}); });
......
...@@ -117,8 +117,8 @@ $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) { ...@@ -117,8 +117,8 @@ $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
"actions": { "actions": {
"primary": { "primary": {
"text": "Dismiss", "text": "Dismiss",
"click": function(model) { "click": function() {
model.hide(); this.hide();
} }
} }
} }
......
...@@ -248,8 +248,8 @@ CMS.Views.SectionEdit = Backbone.View.extend({ ...@@ -248,8 +248,8 @@ CMS.Views.SectionEdit = Backbone.View.extend({
actions: { actions: {
primary: { primary: {
text: "Dismiss", text: "Dismiss",
click: function(model) { click: function() {
model.hide() this.hide()
} }
} }
} }
......
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