Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Div not visible inside popup #117

Open
mdurazob opened this issue Aug 28, 2017 · 1 comment
Open

Div not visible inside popup #117

mdurazob opened this issue Aug 28, 2017 · 1 comment

Comments

@mdurazob
Copy link

mdurazob commented Aug 28, 2017

Hi

I am trying to put a HighCharts inside the default popup table that comes with this code:

`onEachRecord: function (layer,record) {
var $html = $(L.HTMLUtils.buildTable(record));

		layer.bindPopup($html.wrap('<div/>').parent().html(),{
			minWidth: 600,
			maxWidth: 700
		});
	},

`

The code for the records is this:

var NLpopdens =[ { "CODIGO": "01", "NAME": "10", "POPU": "635100", "AREA": "162.18", "Density": "Title<br/><img src='http://joshuafrazier.info/images/maptime.gif' alt='maptime logo gif' width='350px'/>" }, { "CODIGO": "02", "NAME": "11", "POPU": "263500", "AREA": "227.11", "Density": "Title<br/><div id='container' style='width:200px; height:300px;'></div>" },

I was able to do it using an image for the row of Density, but not a DIV. Does anyone know how to solve this?

PS. The code for the HighChart

Highcharts.chart('container', { chart: { type: 'area' }, title: { text: 'Area chart with negative values' }, xAxis: { categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas'] }, credits: { enabled: false }, series: [{ name: 'John', data: [5, 3, 4, 7, 2] }, { name: 'Jane', data: [2, -2, -3, 2, 1] }, { name: 'Joe', data: [3, 4, 4, -2, 5] }] });

And the Console in the browser gives me the following error:

Uncaught Error: Highcharts error #13: www.highcharts.com/errors/13
at Object.a.error (highcharts.js:10)
at a.Chart.getContainer (highcharts.js:258)
at a.Chart.firstRender (highcharts.js:273)
at a.Chart.init (highcharts.js:249)
at a.Chart.getArgs (highcharts.js:248)
at new a.Chart (highcharts.js:247)
at Object.a.chart (highcharts.js:247)
at HTMLDocument. (conflictdata.html:679)
at c (jquery-1.9.1.min.js:3)
at Object.fireWith [as resolveWith] (jquery-1.9.1.min.js:3)

@sfairgrieve
Copy link
Contributor

I think this is an issue with the element not existing in the DOM when you call the Highcharts initialization code. When you call bindPopup, it's telling Leaflet to display the associated HTML when a user clicks on that layer. The associated HTML that you're passing to bindPopup is not part of the DOM until the layer is clicked and the popup is displayed. I would suggest handling the layer click event in onEachFeature and generating the HTML there, then passing the DOM element after Highcharts initialization to the bindPopup method followed by a call to openPopup. Does that make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants