Skip to content

Instantly share code, notes, and snippets.

@thomsbg
Last active December 22, 2015 22:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomsbg/6541380 to your computer and use it in GitHub Desktop.
Save thomsbg/6541380 to your computer and use it in GitHub Desktop.
Using this.ajax inside a model
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