Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uncaught TypeError: Object #<Object> has no method 'get'
- ListingCollection = Backbone.Collection.extend({
- model: Listing,
- url: '/api/search_by_bounds',
- fetchNew: function(options) {
- options = options || {};
- var collection = this,
- success = options.success;
- options.success = function(resp, status, xhr) {
- _(collection.parse(resp, xhr)).each(function(item) {
- // added this conditional block
- if (!collection.get(item.id)) {
- collection.add(item, {silent:true});
- new ListingMarkerView({ model:item }).render();
- }
- });
- if (!options.silent) {
- collection.trigger('reset', collection, options);
- }
- if (success) success(collection, resp);
- };
- return (this.sync || Backbone.sync).call(this, 'read', this, options);
- }
- });
- ListingMarkerView = Backbone.View.extend({
- render: function() {
- var marker = L.marker([this.model.get('lat'), this.model.get('lng')]);
- markers.addLayer(marker);
- },
- close: function() {
- this.unbind;
- }
- });
- my_collection.fetch({success: function(collection, resp){
- collection.reset(resp, {silent: true});
- }});
Add Comment
Please, Sign In to add comment