Ok so here is a problem,
I have an html template which looks something like this:
<script>
$(function() {
var vCountries = {{ visitedCountriesList }};
});
</script>
<..>
{{ visitedCountriesList }}
from server I pass an list to this item, but after rendering it looks like this:
<script>
$(function() {
var vCountries = ;
});
</script>
<..>
[u'Afghanistan', u'Japan', u'United Arab Emirates']
so my question is – why ? and how I can pass it to javascript…?
you should have in your html an id with the variable rendered and look it there, lets do an example:
and in your javascript:
That is assuming you are using jQuery.
I dont really know why that template assign the variable but you should not render any information on javascript code since there is a moment where you are going to take that js and put it on a compressed file, or move it, or reuse it and it will be really hard to do it if you rendered the variable values that way.
hope this helps!