I keep getting Uncaught SyntaxError: Unexpected token ILLEGAL in my {% endfor %} line – I’m using jinja2 in Google app engine python server code and the error is in one of my html templates:
I’m trying to create a menu of categories that show subcategories contingent on what parent category was picked – I want it to slide toggle to show sub categories. I’m new to JS/Jquery. Any ideas on what is wrong with my syntax??
function create_first() {
var first_level = "<div id='colOne'>";
{% for each in by_subject_level1 %}
first_level+= "{{each.name1}}<br />";
{% endfor %};
$(#filtered_courses).append(first_level);
}
Let’s see.. to fix your immediate problems:
$(#filtered_courses).append(first_level);->$("#filtered_courses").append(first_level);{% endfor %}, but I’m pretty sure that isn’t causing any issuesOne suggestion: string concatenation — meh (depending on the size of your
by_subject_level1list). instead of +=, create an array ([]), push your content, and then join usingi.e.