이것이 일반적인 문제라는 것을 알고 있습니다. 나는이 사이트와 다른 곳에서 제안 된 다양한 솔루션을보고 있었지만 내 상황에서 효과가있는 것을 공격 할 수는 없습니다. 여기 jQuery UI 대화 상자 유효성 검사
내 스크립트입니다$(function() {
$('a.editPersonLink').live("click", function (event) {
loadDialog(this, event, '#personList');
$.validator.unobtrusive.parse('#editPersonContainer');
});
$(".deleteButton").live("click", function(e) {
e.preventDefault();
var $btn = $(this);
var $msg = $(this).attr("title");
confirmDelete($msg,
function() {
deleteRow($btn, $target);
});
});
});
function loadDialog(tag, event, target) {
event.preventDefault();
var $loading = $('<img src="../../Content/images/ajaxLoading.gif" alt="loading" class="ui-loading-icon">');
var $url = $(tag).attr('href');
var $title = $(tag).attr('title');
var $dialog = $('<div></div>');
$dialog.empty();
$dialog
.append($loading)
.load($url)
.dialog({
autoOpen: false
,title: $title
,width: 800
,modal: true
,minHeight: 200
,show: 'slide'
,hide: 'clip'
});
$dialog.dialog("option", "buttons", {
"Save": function() {
var dlg = $(this);
$.ajax({
url: $url,
type: 'POST',
data: $("#formData").serialize(),
success: function (response) {
$(target).html(response);
dlg.dialog('close');
dlg.empty();
$("#ajaxResult").hide().html('Record saved').fadeIn(300, function() {
var e = this;
setTimeout(function() { $(e).fadeOut(400); }, 2500);
});
},
error: function (xhr) {
if (xhr.status == 400)
dlg.html(xhr.responseText, xhr.status); /* display validation errors in edit dialog */
else
displayError(xhr.responseText, xhr.status); /* display other errors in separate dialog */
}
});
},
"Cancel": function() {
$(this).dialog("close");
$(this).empty();
}
});
$dialog.dialog('open');
};
오른쪽 난 문을 통해 대화의 부분보기에서 유효성 검사를 인식 할 양식을 야기하려고 상단까지 :
$.validator.unobtrusive.parse('#editPersonContainer');
editPersonContainer는 대화 상자에로드 된 부분 뷰의 데이터를 포함하는 div의 이름입니다.
결론은 유효성을 인정하지 않는다는 것입니다. 틀린 장소에서 validator.unobtrusive.parse를 호출합니까? 아니면 여기에 다른 것을 놓치고 있습니까? 나는이 기술을 이용할 수 있도록 스크립트를 변경 결국
에 전체 프로젝트에 기사를합니다
나는 클라이언트 측에서 유효성을 검사하는 아약스 호출하기 전에이 포함 jqui 대화? 렌더링 된 ''요소는 어떻게 생겼습니까? 그들은'data-val = "true"'속성을 가지고 있습니까? – danludwig