I am using Backbone.js (version 0.5.3) and I am having problems with a successful callback when saving the model . It does not start, although the model is successfully saved on the server.
CoffeeScript:
console.log 'in switch_private' console.log "private_entry attribute is currently #{@model.get('private_entry')}" @model.save {'private_entry': true}, success: -> console.log 'in success'
Compiled Javascript:
console.log('in switch_private'); console.log("private_entry attribute is currently " + (this.model.get('private_entry'))); return this.model.save({ 'private_entry': true }, { success: function() { return console.log('in success'); } });
Console output:
in switch_private private_entry attribute is currently false XHR finished loading: "http://localhost:3000/entries/235".
I am returning head :ok from the update action in Ruby on Rails.
Adding model and response arguments, so this is success: (model, response) -> , doesn't matter. What is going wrong?
EDIT: As suggested by Trevor Burnham, I have added an error callback and it starts. So what should I return from a Ruby on Rails action in order for Backbone to account for success? At the moment I have head :ok
EDIT 2: Here is my updated compiled Javascript:
var this_view; this_view = this; return this.model.save({ 'private_entry': !(this.model.get('private_entry')) }, { success: function(model, response) { return console.log('in success'); }, error: function(model, response) { return console.log('in error'); } });
Here is the PUT request:

ben
source share