I am using MVC 3 with unobtrusive javascript to validate the client.
I have a table with rows that can be clicked. When I click, I want to invoke a dynamically loaded partial view. This is the code for this:
function GetStuff(id) {
$.ajax(
{
url: "Edit/" + id,
success: function (result) {
$("#DivTest").html(result);
}
});
}
So far, everything is working. The problem is that I am trying to save something in partial use of jquery. The form is stolen, for example:
$(function () {
$.post($(this).attr("action"),
$(this).serialize(),
function (data) {
alert("test");
});
e.preventDefault();
});
All this makes the client check inoperative. It just makes a message, even if I do not take into account some of the required values. All this works if I do not use ajax to publish or if a partial download is loaded on a page (not dynamic).
What I tried:
I tried to put this before publishing:
if($('form').validate().form()){
...
}
It just returns true every time, though ..
2
ASP.NET MVC 2 jQuery -
Sys.Mvc.FormContext._Application_Load();
.
"html". .
:
http://www.deepcode.co.uk/2010/08/mvc-ootb-validation-when-pulling-in.html
- , , ? .