Created
April 17, 2014 13:11
-
-
Save whosaysni/10982282 to your computer and use it in GitHub Desktop.
Confirmation/submit dialog with MetroUI css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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