firebase/backfire — pull request #34 by jimrubenstein (2013-07-14 13:22:21+00:00)
Title: Some updates for underscore >= 1.5.0, fixing the Sync method, and simplifying the Backbone.Collection constructor

I'd been struggling for several hours trying to figure out how to get this Backbone plugin to work. Turns out there were a few items that were my fault (particuarly, not setting my `firebase` property in my model/collection definition to a Backbone.Firebase object, instead of just a Firebase object). But some weren't, this prompted me to comb through the source code to find out what was happening and where things were going wrong under the hood. I found a few things that needed updating:

The `_.bindAll` call in the `Backbone.Firebase` constructor is no longer supported as of underscore 1.5.0 (here: https://github.com/jashkenas/underscore/issues/992, here: https://github.com/jashkenas/underscore/issues/1033, and here: https://github.com/jashkenas/underscore/commit/bf657be243a075b5e72acc8a83e6f12a564d8f55).

The call to `store[method].apply()` in `Backbone.Firebase.sync` sets the incorrect context of `this` instead of `store`.

I also found an improvement that could be made in the `Backbone.Firebase.Collection` constructor in regards to attaching/detaching event listeners for models' `change` events. I went ahead and patched that up to.

Let me know if there are any problems with this PR, I'll be happy to fix them. If you want some but not all of these changes, I'll be glad to submit separate PRs for them if required.

I hope this helps and keeps the next person from spending several hours, many beers (is this really a bad thing?), and lots of frustration trying to figure out what is going on any why things "just don't work."