SHARE
TWEET

Untitled

a guest Jan 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Uncaught TypeError: Object #<Object> has no method 'get'
  2.    
  3. ListingCollection = Backbone.Collection.extend({
  4.     model: Listing,
  5.     url: '/api/search_by_bounds',
  6.  
  7.     fetchNew: function(options) {
  8.         options = options || {};
  9.         var collection = this,
  10.             success = options.success;
  11.         options.success = function(resp, status, xhr) {
  12.             _(collection.parse(resp, xhr)).each(function(item) {
  13.                 // added this conditional block
  14.                 if (!collection.get(item.id)) {
  15.                     collection.add(item, {silent:true});
  16.                     new ListingMarkerView({ model:item }).render();
  17.                 }
  18.             });
  19.             if (!options.silent) {
  20.                 collection.trigger('reset', collection, options);
  21.             }
  22.             if (success) success(collection, resp);
  23.         };
  24.         return (this.sync || Backbone.sync).call(this, 'read', this, options);
  25.     }
  26. });
  27.    
  28. ListingMarkerView = Backbone.View.extend({
  29.  
  30.     render: function() {
  31.         var marker = L.marker([this.model.get('lat'), this.model.get('lng')]);
  32.         markers.addLayer(marker);
  33.     },
  34.  
  35.     close: function() {
  36.         this.unbind;
  37.     }
  38.  
  39. });
  40.    
  41. my_collection.fetch({success: function(collection, resp){
  42.     collection.reset(resp, {silent: true});
  43. }});
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top