Disable delete button by default, when clicked

This commit is contained in:
Lance Edgar 2016-10-16 03:30:42 -05:00
parent 7e3d47aa5c
commit 1327b886fc

View file

@ -3,6 +3,20 @@
<%def name="title()">Delete ${model_title}: ${instance_title}</%def> <%def name="title()">Delete ${model_title}: ${instance_title}</%def>
<%def name="head_tags()">
${parent.head_tags()}
<script type="text/javascript">
$(function() {
$('#confirm-delete').click(function() {
$(this).button('disable').button('option', 'label', "Deleting, please wait...");
$(this).parents('form').submit();
});
});
</script>
</%def>
<%def name="context_menu_items()"> <%def name="context_menu_items()">
<li>${h.link_to("Back to {}".format(model_title_plural), url(route_prefix))}</li> <li>${h.link_to("Back to {}".format(model_title_plural), url(route_prefix))}</li>
% if master.viewable and request.has_perm('{}.view'.format(permission_prefix)): % if master.viewable and request.has_perm('{}.view'.format(permission_prefix)):
@ -19,11 +33,12 @@
<%def name="confirmation()"> <%def name="confirmation()">
<br /> <br />
<p>Are you sure about this?</p> <p>Are you sure about this?</p>
<br />
${h.form(request.current_route_url())} ${h.form(request.current_route_url())}
<div class="buttons"> <div class="buttons">
<button type="button" onclick="$(this).parents('form').submit();">Yes, please DELETE this record forever!</button>
<a class="button" href="${form.cancel_url}">Whoops, nevermind...</a> <a class="button" href="${form.cancel_url}">Whoops, nevermind...</a>
<button type="button" id="confirm-delete">Yes, please DELETE this data forever!</button>
</div> </div>
${h.end_form()} ${h.end_form()}
</%def> </%def>
@ -32,7 +47,8 @@
${self.context_menu_items()} ${self.context_menu_items()}
</ul> </ul>
<p>You are about to delete the following ${model_title} record:</p> <br />
<p>You are about to delete the following ${model_title} and all associated data:</p>
<div class="form-wrapper"> <div class="form-wrapper">
${form.render()|n} ${form.render()|n}