I have a list of objects and when I click on one of them, I open a Popup (DevExpress PopupControl) containing the inputs filled correctly accordingly to the object clicked.
To render this, I make a AJAX call, (jQuery.ajax) that replaces the 'body' of the popup and then opens it; the server answers with a partial view containing the entire form):
var $self = $(this);
var _idSoc = $self.data("id");
var options = {
url: "@Url.Action("GetPopupEditSoc", "Home")",
type: "post",
data: { idSoc: _idSoc }
};
$.ajax(options)
.done(function (data) {
$(".container-popupEdit").empty().append(data);
PopupEditSociete.Show();
$.validator.unobtrusive.parse(document);
})
.fail(function (data) {
console.log("Error: ", data);
});
The problem it that creating a popup in this way I lose the validation on the Client side.
I've already tryed (of course, all the scripts are in the current page) - $.validator.unobtrusive.parse(document); - on Ajax.BeginForm Options, onSuccess doesn't work.. it is never called
THE CONTENT OF THE POPUP:
@{
Html.EnableClientValidation();
Html.EnableUnobtrusiveJavaScript();
}
@using (Ajax.BeginForm("ModificationSociete", "Home",
new AjaxOptions
{
OnSuccess = "console.log('???')",
OnBegin = "AjaxFormEditSoc_OnBegin",
OnComplete = "AjaxFormEditSoc_OnComplete",
UpdateTargetId = "container-EditSocForm",
InsertionMode = InsertionMode.Replace
},
new
{
id = "FormModificationSoc"
}))
{
<div style="padding: 10px;" id="container-EditSocForm"> ......
Any ideas????