In my current Backbone app, I have no problems creating or destroying
models. The changes propagate to my server without any problems. But
whenever I try to do a model.save(attributes), I see a TypeError
thrown at this line: https://github.com/documentcloud/backbone/blob/master/backbone.js#L117
The model is updated on the (Rails) server, but something breaks
afterward. Here’s the stack trace. (Sorry, line numbers refer to
concatenated JS files.)
Backbone.Events.trigger() at application.js:11574
_.extend._onModelEvent() at application.js:12092
d() at (internal script):1426Backbone.Events.trigger() at
application.js:11574
_.extend.change() at application.js:11808
_.extend.set() at application.js:11680
_.extend.save() at application.js:11753
Map.mapMoveGeoPointMode() at app.js:741
(anonymous function)() at app.js:894
jQuery.event.handle() at application.js:2966
jQuery.event.add.elemData.handle.eventHandle() at application.js:2600
In previous applications, I’ve had no little problems on saving models
like this. Any suggestions for what to look at?
Note: I don’t think I’m repeating this fellow’s problem of trying to save a model with no URL.
Given that the model is updated properly on the server, I don’t think this has anything to do with the
save()function itself, but rather with thechangeevent it’s triggering – I think you could test this simply by callingmyModel.trigger('change')and seeing if that throws the same error.My best guess as to why this is happening is that somewhere along the way you’re binding something other than a function – e.g. an undefined variable – to the
changeevent. I’d look for an error like this:but it’s pretty much impossible to debug further without seeing actual code, not just a stack trace.