I am toying around with some jQuery on a callback from an MVC Ajax Action Link
@Ajax.ActionLink("Sign In", "SignIn", "Account", null, new AjaxOptions { OnSuccess = "SignInForm.onSuccess",UpdateTargetId = "content-panel-inner",HttpMethod = "get"}, new { @id = "sign-in" })
Here is the callback:
var SignInForm = {
onSuccess: function (data, textStatus) {
var form ='#' + $(data).find('form').attr('id');
jQuery.validator.unobtrusive.parse($(form));
console.log(data);
}
};
As you can see fairly simple. I am even throwing data to the console right… My question is this, what if there is more than one form being returned from the initial ajax call? What is the easiest way to get a collection of form elements? A .each maybe?
I don’t know how the validator really works, but if there are multiple forms, then you can loop over them like this:
Also, your example is very roundabout. You can just pass the element directly instead of using the id: