我正在尝试在表单提交上调用命名函数。这是代码:
$(document).ready(function() {
showPartnerSettings = function(e) {
e.preventDefault();
var $dialogForm = $("<div />")
.attr("id", "partner-settings-form")
.append($loading.clone())
.load(envPath + "/partner/settings?partnerid="+e.data.partnerId, null, function(){ $("#partner-settings-form").css("display", "block"); })
.dialog({
title: "Partner Settings",
modal: false,
resizable: false,
width: 580, //CPB 04.11.13
position:['middle',130],
"close" : function(){
var dialogid=$(this).parent("div").attr("id");
$("#Tabs ul li."+dialogid).remove();
$(this).remove();
$("#alertmod").remove();
//$link.removeClass('preventclick');
},
})
.dialog("open")
.css("display", "block");
return false;
};
$("#partner-settings-form").submit(function(event) { return showPartnerSettings(event); });
当我在 showPartnerSettings() 上设置断点时,它不会在 .submit() 函数执行后中断。为什么?
编辑:
这是 Jasen 请求的 HTML:
<div id="partner-settings-form" style="display: block; width: auto; min-height: 66.6875px; height: auto;" class="ui-dialog-content ui-widget-content" scrolltop="0" scrollleft="0">
<article class="sign_in form-dialog clearfix">
<div class="bg-form-dlg">
<div class="col_100 clearfix">
<h2>UPS Shipping Information</h2>
<form enctype="application/x-www-form-urlencoded" class="sign_in_form sign_up_form" action="" method="post"><div class="zend_form">
<div class="shippingdetails"><fieldset id="fieldset-account">
<div id="key-label" class="formlabel"><label for="key" class="required">Access Key: *</label></div>
<div id="key-element" class="formcontent">
<input type="text" name="key" id="key" value="CCA574143AD81C1A "></div>
<div id="id-label" class="formlabel"><label for="id" class="required">User ID: *</label></div>
<div id="id-element" class="formcontent">
<input type="text" name="id" id="id" value="argoworks"></div>
<div id="password-label" class="formlabel"><label for="password" class="required">Password: *</label></div>
<div id="password-element" class="formcontent">
<input type="text" name="password" id="password" value="Ubond007gun"></div>
<div id="account_number-label" class="formlabel"><label for="account_number" class="required">Account Number: *</label></div>
<div id="account_number-element" class="formcontent">
<input type="text" name="account_number" id="account_number" value="8X6124"></div>
<div id="address1-label" class="formlabel"><label for="address1" class="required">Address1: *</label></div>
<div id="address1-element" class="formcontent">
<input type="text" name="address1" id="address1" value="112.5 South La Brea Ave."></div>
<div id="address2-label" class="formlabel"><label for="address2" class="optional">Address2:</label></div>
<div id="address2-element" class="formcontent">
<input type="text" name="address2" id="address2" value=""></div>
<div id="phone-label" class="formlabel"><label for="phone" class="required">Phone: *</label></div>
<div id="phone-element" class="formcontent">
<input type="text" name="phone" id="phone" value="2147483647"></div>
<div id="city-label" class="formlabel"><label for="city" class="required">City: *</label></div>
<div id="city-element" class="formcontent">
<input type="text" name="city" id="city" value="Los Angeles"></div>
<div id="state-label" class="formlabel"><label for="state" class="required">State (code): *</label></div>
<div id="state-element" class="formcontent">
<input type="text" name="state" id="state" value="CA"></div>
<div id="country-label" class="formlabel"><label for="country" class="optional">Country:</label></div>
<div id="country-element" class="formcontent" style="">
<select name="country" id="country" class="dlg-select">
<option value="US" label="UNITED STATES" selected="selected">UNITED STATES</option>
<option>...etc...</option>
</select></div>
<div id="postal-label" class="formlabel"><label for="postal" class="required">Postal Code: *</label></div>
<div id="postal-element" class="formcontent">
<input type="text" name="postal" id="postal" value="90036"></div></fieldset></div>
<div>
<p><label id="configship-label"> </label>
<input type="submit" name="configship" id="configship" value="Save Information"></p></div></div></form></div>
</div>
</article>
UPS342hi</div>
我在您的帮助下发现了问题。我没有将 .submit() 附加到表单元素。现在我正在尝试解决这个问题,但我遇到了另一个问题。你知道我如何从 JS 访问 POSTed 表单数据吗?我需要访问表单中名为“partnerId”的隐藏字段。表单数据是否包含在 event.data 中?感谢您的持续帮助。