Skip to content

Instantly share code, notes, and snippets.

@tekniklr
Created May 11, 2012 18:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekniklr/2661694 to your computer and use it in GitHub Desktop.
Save tekniklr/2661694 to your computer and use it in GitHub Desktop.
Example of using modal confirmation dialog in jQuery
<div id="modal-submit-once" title="Are you sure?" style="display:none">
<p>This form can only be submitted once. Are you sure you want to submit it now?</p>
</div>
<input type="button" id="submit_form" value="Submit" />
<script type="text/javascript">
$("div[id^='modal-submit-once']").dialog({
modal: true,
autoOpen: false,
width: 400,
buttons: {
"Yes, I'm sure": function() {
$("#<%= @form.view_name %>").submit();
$( this ).dialog( "close" );
},
"No, wait!": function() {
$( this ).dialog( "close" );
}
}
});
$("input[id^='submit_form']").click(function(){
$("div#" + 'modal-submit-once').dialog("open");
return false;
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment