2👍
✅
When you generate HTML from code, you still have access to onclick events.
return mark_safe('<a href="{0}" Delete class="delete" onclick='delete_action()'><img src="{1}"></a>'.format(href, url)
Now your delete_action
can be a javascript function that gives you more control. Generated HTML is basically just any old type of HTML, so you can still use jquery event handlers with it
BTW, please note how string formatting has been used in stead of concatenation. This is more pythonic
👤e4c5
Source:stackexchange.com