私はasp.net mvc3アプリケーションでクライアントの検証に問題があります。asp.net mvc3 jquery uiダイアログとクライアントの検証
私のコードでは、なります
function loadEditCategoryDialog(categoryId) {
$.ajax({
url : "/rovastamp3/Admin/CategoryEditDialog",
data : "categoryId="+categoryId,
success : function(data){
$("#popup_dialog").html(data);
$("#popup_dialog").dialog({
modal: true,
draggable: false,
resizable: false,
title: "Upravit kategorii",
width: 600,
height: 500,
});
}
});
}
コントローラー:
[HttpGet]
public ActionResult CategoryEditDialog(int categoryId)
{
CategoryEditViewModel categoryEditViewModel = new CategoryEditViewModel();
categoryEditViewModel.Category = _postAuctionCategoryRepo.Query()
.SingleOrDefault(x => x.Id == categoryId);
return PartialView(categoryEditViewModel);
}
[HttpPost]
public ActionResult CreateNewCategory(CategoryEditViewModel categoryEditViewModel)
{
if (ModelState.IsValid)
{
return RedirectToAction("Index");
}
return View("CategoryEditDialog", categoryEditViewModel);
}
そして最後に、私の部分図:私のweb.configファイルで
@model Rovastamp.MVC3.ViewModels.AdminController.CategoryEditViewModel
<h2>Upravit kategorii @Model.Category.Name</h2>
@{Html.EnableClientValidation();}
@using (Html.BeginForm("CreateNewCategory", "Admin"))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Objednávkový formulář</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Category.Name)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Category.Name)
@Html.ValidationMessageFor(model => model.Category.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Category.Position)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Category.Position)
@Html.ValidationMessageFor(model => model.Category.Position)
</div>
<input type="submit" value="Upravit" class="submit_button" />
</fieldset>
}
私はUnobtrusiveJavaScriptとClientValidatinアプリの設定をオンに。
jquery UIダイアログのサブミットボタンをクリックすると、mvcはクライアントの検証なしで完全に更新されますか?
問題はどこですか?私のレイアウトページで
私はこのスクリプトを含める:
- jquery.unobtrusive-ajax.js
- jquery.validate.js 任意のヘルプ
- jquery.validate.unobtrusive.js
EDITため
感謝
は私が入れ:
私はjqueryのUIダイアログとクライアント検証呼び出す前にjQuery.validator.unobtrusive.parse('#popup_dialog');
は完璧に動作します。
ありがとうございました。それは動作します:) – Mennion
+1私はあなたをより多くのダビドを高めることができます。まさに私が必要としてきたもの。 – gnome
@gnome :)彼のプロフィールを開いて、彼のすべての答えと質問をupvoteすることができます。すべて可能です。 – Omu