Can a Backbone.js View
have a Model
and a Collection
?
The reason I am asking is because I'm working with a View that holds a map with places plotted on it (using the leaflet library).
The Collection
is of a group of models that hold coordinates to be plotted on the map.
The Model
holds stuff like the map bounds and map shape.
Not sure how else to pull this one off...
Any help is appreciated, thanks!
Yes, you can pass it in as simply as:
new view({model: m, collection: c});
and inside the view you can access both with:
this.model
this.collection
jsfiddle for example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With