examples/todos/js/backbonefire.js
function(options) {
          options = options ? _.clone(options) : {};
          if (options.parse === void 0) { options.parse = true; }
          var success = options.success;
          var collection = this;
          options.success = function(resp) {
            var arr = [];
            var keys = _.keys(resp);
            _.each(keys, function(key) {
              arr.push(resp[key]);
            });
            var method = options.reset ? 'reset' : 'set';
            collection[method](arr, options);
            if (success) { success(collection, arr, options); }
            options.autoSync = false;
            options.url = this.url;
            collection.trigger('sync', collection, arr, options);
          };
          return this.sync('read', this, options);
        }
function(options) {
          options = options ? _.clone(options) : {};
          if (options.parse === void 0) { options.parse = true; }
          var success = options.success;
          var collection = this;
          options.success = function(resp) {
            var arr = [];
            var keys = _.keys(resp);
            _.each(keys, function(key) {
              arr.push(resp[key]);
            });
            var method = options.reset ? 'reset' : 'set';
            collection[method](arr, options);
            if (success) { success(collection, arr, options); }
            options.autoSync = false;
            options.url = this.url;
            collection.trigger('sync', collection, arr, options);
          };
          return this.sync('read', this, options);
        }
function ( options ) { options = options ? _ . clone ( options ) : { } ; if ( options . parse === void 0 ) { options . parse = true ; } var success = options . success ; var collection = this ; options . success = function ( resp ) { var arr = [ ] ; var keys = _ . keys ( resp ) ; _ . each ( keys , function ( key ) { arr . push ( resp [ key ] ) ; } ) ; var method = options . reset ? 'reset' : 'set' ; collection [ method ] ( arr , options ) ; if ( success ) { success ( collection , arr , options ) ; } options . autoSync = false ; options . url = this . url ; collection . trigger ( 'sync' , collection , arr , options ) ; } ; return this . sync ( 'read' , this , options ) ; }
Firebase returns lists as an object with keys, where Backbone
collections require an array. This function modifies the existing
Backbone.Collection.fetch method by mapping the returned object from
Firebase to an array that Backbone can use.
Firebase returns lists as an object with keys where Backbone collections require an array . This function modifies the existing Backbone . Collection . fetch method by mapping the returned object from Firebase to an array that Backbone can use .