Message action callbacks have model set to this
This commit is contained in:
@@ -13,19 +13,20 @@ CMS.Models.SystemFeedback = Backbone.Model.extend({
|
||||
"primary": {
|
||||
"text": "Save",
|
||||
"class": "action-save",
|
||||
"click": function(model) {
|
||||
"click": function() {
|
||||
// do something when Save is clicked
|
||||
// `this` refers to the model
|
||||
}
|
||||
},
|
||||
"secondary": [
|
||||
{
|
||||
"text": "Cancel",
|
||||
"class": "action-cancel",
|
||||
"click": function(model) {}
|
||||
"click": function() {}
|
||||
}, {
|
||||
"text": "Discard Changes",
|
||||
"class": "action-discard",
|
||||
"click": function(model) {}
|
||||
"click": function() {}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
|
||||
primaryClick: function() {
|
||||
var primary = this.model.get("actions").primary;
|
||||
if(primary.click) {
|
||||
primary.click(this.model);
|
||||
primary.click.call(this.model);
|
||||
}
|
||||
},
|
||||
secondaryClick: function(e) {
|
||||
@@ -38,7 +38,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
|
||||
var i = _.indexOf(this.$(".action-secondary"), e.target);
|
||||
var secondary = this.model.get("actions").secondary[i];
|
||||
if(secondary.click) {
|
||||
secondary.click(this.model);
|
||||
secondary.click.call(this.model);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -117,8 +117,8 @@ $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
|
||||
"actions": {
|
||||
"primary": {
|
||||
"text": "Dismiss",
|
||||
"click": function(model) {
|
||||
model.hide();
|
||||
"click": function() {
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,8 +248,8 @@ CMS.Views.SectionEdit = Backbone.View.extend({
|
||||
actions: {
|
||||
primary: {
|
||||
text: "Dismiss",
|
||||
click: function(model) {
|
||||
model.hide()
|
||||
click: function() {
|
||||
this.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user