Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. window.ArtistCollection = Backbone.Collection.extend({
  2.     initialize: function(models, ops) {
  3.         if(ops.updater) {
  4.             this.updater = ops.updates;
  5.             this.updater.bind('update', _.bind(this.onUpdater, this));
  6.         }
  7.     },
  8.    
  9.     onUpdater: function(response) {
  10.         // send the updates to the correct model
  11.         // id. Maybe even as a parse args if its
  12.         // in full model json
  13.     }
  14. });
  15.  
  16. // then just
  17. var popArtists = new ArtistCollection(null, {updater: window.fayeClient});
  18. var trackedArtists = new ArtistCollection(null, {updater: window.fayeClient});
  19.  
  20. // if this is a common pattern, you could wrap it into a new Backbone base