I am trying to assign some javascript variables in a Django template.
I had a problem when the values assigned by me are written to the page correctly (I see them in the page source), but still appear as null.
I'm doing it:
<script type="text/javascript">
var coords = [];
{% for i in item_list %}
coords.push([ {{i.x}}, {{i.y}} ]);
{% endfor %}
</script>
This is the source of the page that is being created:
coords.push([ -320.435118373, -149.333637576 ]);
coords.push([ -120.41321373 , -329.312376 ]);
...
This seems like absolutely correct javascript, however, using Firebug to view the value coords, this is what is produced:
[[null, null], [null, null], [null, null]...[null, null]]
So, it is obvious that each of the calls push()goes right and each time a new array of size 2 is added. However, for some reason, numeric literals are evaluated to null.
Does anyone know how I can use these values correctly?
UPDATE: , , jQuery flot:
$.plot($('#mapWrapper'), coords, options);
, , , Django. , , $.plot.