【发布时间】:2017-02-20 21:12:30
【问题描述】:
我正在使用 MVC3 并添加了具有所需属性的模型验证。然后我创建了具有 jquery 对话框(不是 ajax 对话框)的页面。在这种情况下,验证不起作用。但是,如果我将 html 从对话框放到页面,它就可以正常工作。
有人知道如何解决问题吗?
这是我的 JavaScript:
$(document).ready(function () {
$("#registerDialog").dialog({ autoOpen: false, show: "blind", hide: "explode", modal: true, resizable: false, height: 570, width: 390 });
$(".headerButton").button();
$(".accountBtn").button();
$('ul').roundabout({ autoplay: 'false', autoplayDuration: 3000 });
$("#registerBtn").click(function () {
$("#registerDialog").dialog("open"); return false; });
$("#closeRegisterDialog").click(function () { $("#registerDialog").dialog("close");
});
$("#registerBtnSbmt").click(function () {
$("#registerForm").submit(); return false; });
})
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { id = "registerForm" }))
{
<div id="registerDialog" title="Регистрация">
@Html.LabelFor(x => x.FirstName)
<br/>
@Html.TextBoxFor(x => x.FirstName, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.FirstName)
<br/>
@Html.LabelFor(x => x.LastName)
<br/>
@Html.TextBoxFor(x => x.LastName, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.LastName)
<br/>
@Html.LabelFor(x => x.Email)
<br/>
@Html.TextBoxFor(x => x.Email, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.Email)
<br/>
@Html.LabelFor(x => x.Password)
<br/>
@Html.TextBoxFor(x => x.Password, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.Password)
<br/>
@Html.LabelFor(x => x.ConfirmPassword)
<br/>
@Html.TextBoxFor(x => x.ConfirmPassword, new { @class = "registerUser" })
<br/>
@Html.ValidationMessageFor(x => x.ConfirmPassword)
<br/>
@Html.CheckBoxFor(x => x.RememberYou) запомнить Вас?
<br/>
<br/>
@Html.ActionLink("Сохранить", "LogIn", "Account", null, new { @class = "accountBtn", style = "font-size: 0.8em;", id = "registerBtnSbmt" })
<a href="#" class="accountBtn" id="closeRegisterDialog" style = "font-size: 0.8em;">Закрыть</a>
</div>
}
【问题讨论】:
-
你能贴出你用来生成对话框的代码吗
-
$(document).ready(function () { $("#registerDialog").dialog({ autoOpen: false, show: "blind", hide: "explode", modal: true,可调整大小:假,高度:570,宽度:390 });
-
$(".headerButton").button(); $(".accountBtn").button(); $('ul').roundabout({ autoplay: 'false', autoplayDuration: 3000 }); $("#registerBtn").click(function () { $("#registerDialog").dialog("open"); return false; }); $("#closeRegisterDialog").click(function () { $("#registerDialog").dialog("close"); }); $("#registerBtnSbmt").click(function () { $("#registerForm").submit(); return false; }); });
-
嗯...如何格式化代码?:)
-
你能从 registerDialog 发布 html 吗?
标签: jquery jquery-validate jquery-ui-dialog