I have a Collection App.listingListwhere called fetch()with add:true.
App.listingList.fetch({
data: {some:data},
processData: true,
add: true
});
Problem: . How new models can display their representations without re-visualizing the representations of existing models. This means that I cannot:
this.collection.each( function(listing, index) {
new ListingMarkerView({ model:listing }).render();
}, this);
Attempt # 1
Providing a view in the addevent collection , I can’t figure out how to access the new models for rendering
ListingListView = Backbone.View.extend({
initialize: function() {
this.collection.bind('add', this.renderNew, this);
},
render: function() {
console.log('render ListingListView');
this.collection.each( function(listing, index) {
new ListingMarkerView({ model:listing }).render();
}, this);
return this;
},
renderNew: function() {
new ListingMarkerView({ model:listing }).render();
return this;
}
});
Attempt # 2
fetch on underscore.js _.without(), , , , _difference() , .
App.listingListNew.fetch({
data: {some:data},
processData: true,
success: function() {
console.log(App.listingListNew.models);
console.log(App.listingList.models);
console.log(_.without(App.listingListNew.models, App.listingList.models));
console.log(_.difference(App.listingListNew.models, App.listingList.models));
}
});
console.log
2 _.difference() _.without(), []. :/ , cid , ?
