I've got the following code in a django template:
{% for item in items %}
<tr onclick="{% url collection:viewitem item_id=item.id %}">
<td>{{ item.name }}</td>
<td>{{ item.date }}</td>
<td>
<button onclick="{% url collection:edititem item_id=item.id %}" type="button">Edit</button>
<button onclick="{% url collection:removeitem item_id=item.id %}" type="button">Remove</button>
</td>
</tr>
{% endfor %}
However, the button onclick
events don't work, because the tr onclick
seems to override it. How can I prevent this from happening?
please try the following:
<html>
<body>
<table >
<tr onclick="alert('tr');">
<td><input type="button" onclick="event.cancelBubble=true;alert('input');"/></td>
</tr>
<table>
</body>
</html>
The event.cancelBubble=true will suppress the tr click event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With