[GIS] dynamic content in leaflet popup window

dynamicjavascriptjqueryleaflet

I can add static html code to a Leaflet popup window but can not load a Dygraph chart into a popup window. How does one load dynamic content into a Leaflet popup window?
Here is a simple jsfiddle with a graph and map.
https://jsfiddle.net/scottgeowork/pybvvo27/1/

Best Answer

In order to update the popup content I've added an on click function, and used the popup.setContent method.

marker.on('click', onMarkerClick );
function onMarkerClick(e) {
   var popup = e.target.getPopup();
   var chart_div = document.getElementById("graphdiv");
   popup.setContent( chart_div );
}

https://jsfiddle.net/1k4ujv94/2/