jQuery Mobile: use a dialog to let user confirm form submission

jQuery Mobile: use a dialog to let user confirm form submission

I would like to use the beautiful jQuery Mobile dialog:

<a href="foo.html" data-rel="dialog">Open dialog</a> 

To ask a user if he really wants to submit a form.

My idea is: user fills the form then clicks on submit and so he sees a dialog like "do you really want to submit the form? Yes/No" and if yes the form is sent using ajax to my insert.php page if no the dialog is simply closed.

I've read in the official documentation and it looks like this is simply a graphical tweak to show any #page of my jqm web app like a dialog.

How can I use this dialog page as confirm / cancel of my form submission?

To be clearer: I don't want to use standard javascript like:

function insertClienti() { $('#form').submit(function(e) { if(!confirm('really submit the form?')) { e.preventDefault(); return; } $.post("insert.php", $("#form").serialize()); }); } 

but only jQuery Mobile's dialog.

Thanks for your time and patience.