我有一个提交按钮,它一直在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');
});
答案 0 :(得分: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:)
答案 1 :(得分:-1)
通过对话框我不确定你是指在javascript中使用某个自定义css对话框还是确认对话框。对于后者,这段代码应该可以正常工作。
<!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>