I think, from the point of view of the marker, do you mean the contents of the pop-up window for this marker? You can bind a view as a function popup. At least in the sheet.
The key is that leafy pop-ups allow you to use the provided DOM element as its content. To have the appropriate model knowledge behind the marker, you can specify the marker as a property of the model. This allows you to get the associated model marker. Another way can be achieved by attaching the event to a marker whose signature contains the model.
This is a simplified snippet of my map view, how to configure it after retrieving the collection:
_.each(collection.models, function (model) { var attr = model.attributes, marker = new L.Marker(new L.LatLng(attr.lat, attr.lon)); marker.on('click', function () { App.vent.trigger("model:select", model); }); model.marker = marker; map.addLayer(marker); });
Here, for each model in the collection, a marker is drawn, and then the marker becomes a property of the model. In addition, each marker is associated with a click event that fires the user event "model: select" in the application event aggregator. Here you can use this event to configure a popup by catching an event, for example:
common.vent.on('model:select', function (model) { this.select(model); this.initPopup(model); }, this);
InitPopup might look like this:
initPopup = function (model) { var marker = model.marker, view = new PopupView({model: model}); marker.bindPopup(view.render().el).openPopup(); };
PopupView is a Backbone view (well, Marionette in my case.) Complete with handling templates and events, etc.