Skip to content

Commit

Permalink
provide a default JS handler for confirm-delete in crud-list
Browse files Browse the repository at this point in the history
- vanilla JS since jQuery hasn't normally loaded at that point
- in an overridable block

fixes #117
  • Loading branch information
guruofgentoo committed Jan 29, 2021
1 parent 8f68e07 commit 7b6785a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions keg_auth/templates/keg_auth/crud-list.html
Expand Up @@ -26,4 +26,18 @@ <h1>{{ page_heading }}</h1>
</div>
{{ grid.html() | safe}}
</section>

{% block confirm_delete_script %}
<script type="text/javascript">
var els = document.getElementsByClassName('confirm-delete');

for (var idx = 0; idx < els.length; idx++) {
els[idx].addEventListener('click', function (event) {
if (!confirm('Are you sure you want to delete this item?')) {
event.preventDefault();
}
});
}
</script>
{% endblock %}
{% endblock %}

0 comments on commit 7b6785a

Please sign in to comment.