Dynamic creation of methods/objects with jinja/javascript

I’ve got this working code right now,
For example’ sake I made a straight forward piece of code:

{% for t in things %}
<button id="name{{t.id}}">{{ t.text }}</button>
$('#name{{ t.id }}').on('click', function() {
{% endfor %}

But since this is not a good way to mix html/js I’d like to either put the js in a seperate file or a jinja solution..

Source: javascript

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.