views:

343

answers:

2

I have a submit button which has been working to submit my form in ASP.NET-MVC.

I would like to attach a jQuery dialog to the button click. If the user exits out of the dialog, then I would like to exit from the submit as well.

I have dialogs hooked to other buttons, but not submits. How can I do this?

*EDITED*

This is an example of the dialog I have on another button.

<button type="button" id="create-company" >Create Company</button>

<div id="popupCreateService_Line" title="Create a new service line"> 
<fieldset>
    <label for="service_line_name">Name:</label>
    <%= Html.TextBox("service_line_name") %>

    <label for="service_line_desc">Desc:</label>
    <%= Html.TextBox("service_line_desc") %>

</fieldset>
</div>

$("#create-service_line").click(function() {
                $('#popupCreateService_Line').dialog('open');
            });
A: 

By dialog im not sure if you are referring to some custom css dialog or a confirm dialog in javascript. For the latter this code should work just fine.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
        <title></title>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
    </head>
    <body>
        <form method="get" action="focusout.htm">
            <input type="submit" id="button" value="Submit" />
        </form>
        <script type="text/javascript">

            $("#button").click(function () {
                return confirm("are you sure you want to click?");
            });
        </script>
    </body>
    </html>
wcpro
I don't think this is what the asker had in mind :)
Nick Craver
+1  A: 

attach this to your form load event..

  $(document).bind("keyup.EventPopupEvents", null, function(event)
{
    if (event.keyCode == 27)
    {
        ShutdownEditEventForm();
    }
});

add these two functions:

 function ShutdownEditEventForm(){
$(document).unbind(".EventPopupEvents");
HidePopup($("#EventPopup"));}

function HidePopup($popup){
$("#PopupBackground").hide();
$("#PopupBackground").remove();
$popup.hide();}

add this to your form load for the save:

$("#EditEventSaveButton").click(function() { SaveEvent(id, onSaveCallback); });

hth :)

Avien