Created
May 11, 2012 18:56
-
-
Save tekniklr/2661694 to your computer and use it in GitHub Desktop.
Example of using modal confirmation dialog in jQuery
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
<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