I came across this issue today. I realized that there was significant slowdown on one of my large lists. There is an option to view all, and in that view there is a form per line for deleting items. jquery.validate.unobtrusive
was destroying this page on load. When it was removed, the load was only 2s. Many of the forms needed no validation, but some still did. As a result, i looked in the code for the file and found this:
parse: function (selector) {
/// <summary>
/// Parses all the HTML elements in the specified selector. It looks for input elements decorated
/// with the [data-val=true] attribute value and enables validation according to the data-val-*
/// attribute values.
/// </summary>
/// <param name="selector" type="String">Any valid jQuery selector.</param>
$(selector).find(":input[data-val=true]").each(function () {
$jQval.unobtrusive.parseElement(this, true);
});
$("form").each(function () {//THIS IS THE OFFENDING CODE
var info = validationInfo(this);
if (info) {
info.attachValidation();
}
});
}
I realized that I would need to somehow alter that call, but still retain functionality. What I ended up doing was to mark all of my forms that I did not want to go through this parse method with class="skipValid"
. Then, in the source code, I made this change:
$("form:not(.skipValid)").each(function () {
and I had the best of both worlds.