我正在打开一个查询对话框,它在 MVC 应用程序中有两个查询选项卡。两个标签加载不同的部分页面。我已经在其中一个选项卡中形成。表单验证工作正常。当表单中没有验证错误时,我收到错误 $element[0] is undefined in jquery.validate.js @ line 806 。我无法理解什么问题。下面是代码:
Include references in _Layout.cshtml:
<script src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
Partial view which open in one of tab:
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
@using (Ajax.BeginForm("UpdateMediaCode", "MediaCode", null,
new AjaxOptions
{
UpdateTargetId = "myMsg",
InsertionMode = InsertionMode.Replace,
HttpMethod = "POST",
OnSuccess = "mySuccess"
}, new { @id = "myFormId" }
))
{
@Html.ValidationSummary(true)
}
<script type="text/javascript">
$(document).ready(function () {
$.validator.unobtrusive.parse($('#myFormId));
}
</script>
任何帮助,将不胜感激。这里发生了什么事?