Hi all, I am a beginner in web/javascript programming and wonder if anyone can give me a kick start simple example of a modal confirm dialog just before a form with multiple submit buttons being submitted using a pre-defined button? I stumbled upon jQuery and SimpleModal and wonder if it would fit my ASP MVC project.
I ended up in the following non-working codes, I think my 1st problem is do not know how to return a value from the dialog?:
<script type="text/javascript">
$(document).ready(function() {
$("form").submit(function(ev) {
return confirm("Confirm?");
});
});
function confirm(message) {
$("#confirm").modal({
close: true,
overlayId: "confirmModalOverlay",
containerId: "confirmModalContainer",
onShow: function modalShow(dialog) {
dialog.overlay.fadeIn("slow", function() {
dialog.container.fadeIn("fast", function() {
dialog.data.hide().slideDown("slow");
});
});
dialog.data.find(".confirmMessage").append(message);
dialog.data.find(".btnYes").click(function() {
$.modal.close();
});
}
})
}
</script>
<div id="confirm" style="display:none">
<a href="#" title="Close" class="modalCloseX simplemodal-close">x</a>
<div class="confirmHeader"><span>Confirm</span></div>
<p class="confirmMessage"></p>
<div class="buttons">
<div class="btnYes">Yes</div><div class="btnNo simplemodal-close">No</div>
</div>
</div>
It would be nice if anyone direct me to somewhere online for a crash course of web programming :)