Skip to content

Instantly share code, notes, and snippets.

@chadwilcomb
Last active August 29, 2015 14:01
Show Gist options
  • Save chadwilcomb/67428f87ec07d1a2e1e6 to your computer and use it in GitHub Desktop.
Save chadwilcomb/67428f87ec07d1a2e1e6 to your computer and use it in GitHub Desktop.
Backbone.js: have server return partial view after model.save event
save: function () {
var _this = this;
this.model.save(null, {
error: function (model, response, options) {
//Backbone save goes to error if response is not JSON
if (response.status === 200) {
//check response code and then manually render view with response HTML
_this.$el.html(response.responseText);
}
}
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment