TypeError: Cannot read property 'wait' of undefined
at Object.options.success (http://localhost:3000/javascripts/vendor.js:14850:20)
at UserState.Backbone.sync (http://localhost:3000/javascripts/vendor.js:30692:20)
at UserState..extend.sync (http://localhost:3000/javascripts/vendor.js:14627:28)
at UserState..extend.destroy (http://localhost:3000/javascripts/vendor.js:14859:22)
...
The problem appears to be the replaced Backbone.sync function:
Backbone.sync = (method, model, options) ->
Call options.success() callback to trigger destroy event which triggers
synchronization to other browsers.
if method is "delete"
options.success()
And that goes to this function wrapper in Backbone 0.9.10:
options.success = function(model, resp, options) {
if (options.wait || model.isNew()) destroy();
if (success) success(model, resp, options);
};
Since no parameters are passed to options.success(), options is undefined and options.wait throws an error (as would model.isNew if given the chance).
Changing that line to:
options.success(model, null, options)
Seems to do the trick. Now destroy() doesn't error out for me.
TypeError: Cannot read property 'wait' of undefined
at Object.options.success (http://localhost:3000/javascripts/vendor.js:14850:20)
at UserState.Backbone.sync (http://localhost:3000/javascripts/vendor.js:30692:20)
at UserState..extend.sync (http://localhost:3000/javascripts/vendor.js:14627:28)
at UserState..extend.destroy (http://localhost:3000/javascripts/vendor.js:14859:22)
...
The problem appears to be the replaced Backbone.sync function:
Backbone.sync = (method, model, options) ->
Call options.success() callback to trigger destroy event which triggers
synchronization to other browsers.
if method is "delete"
options.success()
And that goes to this function wrapper in Backbone 0.9.10:
Since no parameters are passed to options.success(), options is undefined and options.wait throws an error (as would model.isNew if given the chance).
Changing that line to:
Seems to do the trick. Now destroy() doesn't error out for me.