Uncaught TypeError: Cannot read property 'unobtrusive' of undefined

时间:2017-03-14 10:22:01

标签: javascript jquery

I have the code below. Clicking on Edit works, clicking on delete fails on

$.validator.unobtrusive.parse($("#modal"));`

saying

"Uncaught TypeError: Cannot read property 'unobtrusive' of undefined"

As I googled it, the solution of this error should be to order javascript includes in proper order, but they are already in correct order I think, and if they weren't, edit would fail as well

<script>

    $('.Edit').click(function () {
        //...

        $.ajax({
            url: "/Client/Edit/?id=" + userId,
            type: "GET",
            success: function (data) {
                $('#modal').html(data);
                $.validator.unobtrusive.parse($("#modal"));
                $('#modal').modal('show');
            }
        });
    });

    $('.Delete').click(function () {
        //...

        $.ajax({
            url: "/Client/_Delete/?id=" + userId,
            type: "GET",
            success: function (data) {
                $('#modal').html(data);
                $.validator.unobtrusive.parse($("#modal"));
                $('#modal').modal('show');
            }
        });
    });
</script>

the generated file includes these in the following order:

    <script src="/Scripts/jquery-1.10.2.js"></script>
    <script src="/Scripts/jquery-ui.js"></script>
...
    <script src="/Scripts/jquery.validate.js"></script>
    <script src="/Scripts/jquery.validate.unobtrusive.js"></script>

0 个答案:

没有答案