Guest User

Untitled

a guest
Jan 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  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. }});
Add Comment
Please, Sign In to add comment