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!
model
andcollection
to something more meaningful. E. g.new MapView({map: mapModel, markers: markersCollection})
. If you opt to do this, don't forget to access them viathis.options.map
or addthis.map = this.options.map; this.markers = this.options.markers
to your map view'sinitialize
method. – Dinar