1👍
This is because in each of the for loops, question_id
is overwritten. You might want to do something like this instead:
$('.chart').each(function() {
var that = this;
var question_id = $(this).attr('id');
$.getJSON('/er/poll/'+question_id ,function(data) {
$(that).highcharts({
...
That way, after rendering the page, you loop through each of the div
s and render the appropriate chart.
Even better: use data-id="{{ book.id }}"
and retrieve it with $(this).data('id')
do avoid using the id attribute for something it’s not really meant for.
Source:stackexchange.com