Skip to content

JS Exception on validation in MVC #11

@Jodith

Description

@Jodith

When using with MVC I get this error: "0x800a138f - JavaScript runtime error: Unable to get property 'attr' of undefined or null reference". The problem is in "onSuccess": I don't have "unobtrusiveContainer" defined and it throws this exception.
Since you check whether "unobtrusiveContainer" exists or not via "if (container)" I think it makes sense to move "replaceAttrValue = container.attr("data-valmsg-replace")" under "if (container)".

function onSuccess(error) {
        var container = error.data("unobtrusiveContainer"),
        replaceAttrValue = container.attr("data-valmsg-replace"),
        replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) : null;

    if (container) {
        container.addClass("field-validation-valid").removeClass("field-validation-error");
        error.removeData("unobtrusiveContainer");

        if (replace) {
            container.empty();
        }
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions