Skip to content

Instantly share code, notes, and snippets.

@whosaysni
Created April 17, 2014 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whosaysni/10982282 to your computer and use it in GitHub Desktop.
Save whosaysni/10982282 to your computer and use it in GitHub Desktop.
Confirmation/submit dialog with MetroUI css
<form id="delete_form"
method="POST" action="{% url 'delete_something' %}">
{% csrf_token %}
<div>
<input type="hidden" name="delete" value="">
<button id="delete_button" type="button">Delete</button>
<script>
$('#delete_button').on('click',
form_confirmation_factory('delete_form',
'Delete', 'Existing something will be removed.', 'OK', 'Cancel'))
</script>
</div>
</form>
form_confirmation_factory = function(form_id, title, message,
ok_label, cancel_label) {
f = function() {
var dlg_content = "<div>"+
"<p>"+message+"</p>"+
"<div class=\"button-set\">"+
"<button type=\"button\" onclick=\"$('#"+form_id+"').submit()\">"+
ok_label+"</button>"+
"<button type=\"button\" onclick=\"$.Dialog.close()\">Cancel</button>"+
"</div>"+
"</div>";
var dlg_params = {
shadow: true, overlay: true, flat: true,
title: title,
padding: 10, width: 300, height: 0,
content: dlg_content
}
var dlg = $.Dialog(dlg_params);
dlg.show();
};
return f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment