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>
<script>
$('#name{{ t.id }}').on('click', function() {
console.log('testingscript');
</script>
{% 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