Uncaught TypeError: Object [object Object] has no method 'dialog'

假如想象 提交于 2019-12-17 10:52:50

问题


I am trying to use the jQueryUI dialog in an MVC3 application but having an issue with it. The dialog I have is loading a partial view into it where the user will either edit or create a new item. This works fine but if I try to save or update the item, or if I try to close it I get the message in the title.

I have added all of the required .js files but still getting the error. I have also used firebug but still can't find why error is happening.

HTML

<span class="EditLink ButtonLink" addressId="@addr.Id">Modify this Address</span>
<div id="popup"></div>

JavaScript

$(document).ready(function () {
    var id = 0;

    //define config object
    var dialogOpts = {
        title: "Edit item",
        modal: true,
        autoOpen: false,
        height: 500,
        width: 500,
        open: function () {
            $("#popup").load("/partialviewtoload/" + id);
        },
        buttons: {
            Cancel: function() {
                $(this).dialog('close');
            }
        }
    };

    $("#popup").dialog(dialogOpts);    //end dialog

    $('.EditLink').click(function() {
        id = $(this).attr("itemId");
        $("#popup").dialog("open");
        return false;
    });    
});

回答1:


issue was that I was referencing "jquery-1.5.1.min.js" twice. Once in the _Layout.cshtml and also in the partial view I was loading. . Removed the reference in the partial view and got it sorted.




回答2:


It seems that browser have not loaded jQueryUI, ensure that it is in your DOM




回答3:


In my case it was that

you should include first grid.locale-en.js and then jquery.jqGrid.min.js.



来源:https://stackoverflow.com/questions/8786104/uncaught-typeerror-object-object-object-has-no-method-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!