So when I am trying to pass a list of country codes to javascript, it does replaces the single quotes -> ' with '
Now I tried to replace all of those with a regular expression, but it would not work. I'm wondering why it will not work to just have those single quotes
function drawRegionsMap() {
for (item in {{countries}}) {
item.replace(/'/g, "'");
}
var data = google.visualization.arrayToDataTable([
{{countries}}
);
In the javascript it's this:
function drawRegionsMap() {
for (item in [['Country'], ['AU'], ['AT'], ['BE'], ['BO'], ... ['LI'], ['MC'], ['ID']]) {
item.replace(/'/g, "'");
}
var data = google.visualization.arrayToDataTable([
[['Country'], ['AU'], ['AT'], ['BE'], ['BO'], ['CO'], ... ['ID']]
);
So do I need to pass this Django variable to the javascript a different way? Is this even possible? All help is appreciated
The error:
SyntaxError: expected expression, got '&'
{% for item in countries %}?{{countries|safe}}, which was provided in the solutions in from that link