div.dialog在JQuery 3.5.1中不是一个函数



所以决定在我的项目中更新一些包,总是有问题。我有一个设置,其中一个链接带来了一个模态对话框与.chtml文件在它。我使用一个名为modaldialogextensions的助手,它调用一个名为modaldialog.js的Javascript文件。当我更新JQuery和Bootstrap时,虽然我不相信更新Bootstrap与它有任何关系,但我的情态显示在页面底部-像stucky。

我在控制台窗口中得到一个错误,说modaldialog.js:30 Uncaught TypeError: div.dialog is not a function,这让我想到了这个:

function openModalDialog(dialogDivId, title) {
var div = $("#" + dialogDivId);
div.dialog({
    title: title,
    close: new Function("clearModalDialog('" + dialogDivId + "');"),
    modal: true,
    width: "auto",
    height: "auto",
    resizable: true 
});
setFormDataAjaxAttributes(dialogDivId);

}

有人知道这个版本的JQuery有什么变化吗?最初的版本是1.10.2。我知道我已经更新到3.x。X什么的,它工作得很好。但这个版本没有。它还在控制台中提到这个文件以及JQuery.unobtrusive-ajax.js。我也更新了这个

完整控制台错误:

modaldialog.js:30 Uncaught TypeError: div.dialog is not a function
at openModalDialog (modaldialog.js:30)
at HTMLAnchorElement.eval (eval at getFunction (jquery.unobtrusive-ajax.js:34), <anonymous>:3:1)
at Object.success (jquery.unobtrusive-ajax.js:105)
at c (jquery-3.5.1.min.js:2)
at Object.fireWith [as resolveWith] (jquery-3.5.1.min.js:2)
at l (jquery-3.5.1.min.js:2)
at XMLHttpRequest.<anonymous> (jquery-3.5.1.min.js:2)

谢谢你的帮助!

更新:

这是moddialog的扩展之一:

 public static MvcHtmlString ModalDialogActionLink(this AjaxHelper ajaxHelper, string linkText, string actionName, string dialogTitle, string CssClass)
    {
        var dialogDivId = Guid.NewGuid().ToString();
        return ajaxHelper.ActionLink(linkText, actionName, routeValues: null,
                ajaxOptions: new AjaxOptions
                {
                    UpdateTargetId = dialogDivId,
                    InsertionMode = InsertionMode.Replace,
                    HttpMethod = "GET",
                    OnBegin = string.Format(CultureInfo.InvariantCulture, "prepareModalDialog('{0}')", dialogDivId),
                    OnFailure = string.Format(CultureInfo.InvariantCulture, "clearModalDialog('{0}');alert('You are not authorized to access this area!')", dialogDivId),
                    OnSuccess = string.Format(CultureInfo.InvariantCulture, "openModalDialog('{0}', '{1}')", dialogDivId, dialogTitle)
                }, htmlAttributes: new { @class = CssClass });
    }

我面临着同样的问题,对话框没有打开,当我调试的东西,发现这是我的Jquery库,我更新了我的Jquery和Jquery min库从1.8到3.5.1的Jquery 3.5.1不支持Jquery对话框了,

由于一些库函数被弃用,如MISE和curCSS,我通过修复这些

来解决它
jQuery.browser = {};
(function () {
    jQuery.browser.msie = false;
        jQuery.browser.msie = true;
        jQuery.browser.version = RegExp.$1;
    }
    
    jQuery.curCSS = function(element, prop, val) {
        return jQuery(element).css(prop, val);
    };

最新更新