alekseykulikov / backbone-offline

[Deprecated] Allows your Backbone.js app to work offline
MIT License
720 stars 56 forks source link

Backbone 1.0 and Backbone 0.9.10 compatibility difference #46

Open rtxanson opened 11 years ago

rtxanson commented 11 years ago

While trying out Backbone.Offline with Backbone 1.0, I uncovered one of the differences. It's nearing the end of the day here, so I won't try to fix and submit a pull request myself, but I thought I'd at least document what I found.

Between 0.9.10 and 1.0, Backbone reverted the API for Backbone.sync success and error callbacks: https://github.com/jashkenas/backbone/commit/6e646f1ba

This this means that with Backbone 1.0, when you run collection.storage.sync.pull(), you get an error such as:

caught TypeError: Cannot use 'in' operator to search for '0' in success 

The problem here of course, is that response ends up being a string "success", not an array of models as the code expects. Unfortunate, because this adds a level of complexity for trying to support both 0.9.10, and 1.0.