2010-04-30 63 views
1

我有一個提交按鈕,它一直在ASP.NET MVC中提交我的表單。附加jQuery對話框提交按鈕ASP.NET-MVC

我想附加一個jQuery對話框到按鈕點擊。如果用戶退出對話框,那麼我想退出提交。

我有掛鉤到其他按鈕,但不提交的對話框。我怎樣才能做到這一點?

**** **** EDITED

這是對話我對另一個按鈕的一個例子。

<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'); 
      }); 

回答

-1

通過對話林不知道,如果你指的是一些自定義的CSS對話框或JavaScript的一個確認對話框。對於後者,這段代碼應該工作得很好。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <title></title> 
     <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
    </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> 
+1

我不認爲這是提問者的想法:) – 2010-04-30 18:18:08

1

附加給你的窗體加載事件..

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

這兩個功能添加:

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

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

添加到您的形式負載保存:

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

hth :)