Last active
December 22, 2015 22:39
-
-
Save thomsbg/6541380 to your computer and use it in GitHub Desktop.
Using this.ajax inside a model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.Models.Comment = Backbone.Model.extend(_.extend({}, App.Mixins.Ajax, { | |
urls: { | |
flag: '/comments/flag_comment/:id' | |
}, | |
flag: function(formData) { | |
this.set('is_flagged', true); | |
return this.ajax('flag', { | |
data: formData, | |
error: function() { | |
this.set('is_flagged', false); | |
} | |
}); | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment