【问题标题】:div.dialog is not a function in Modal Popup JQuery 3.5.1div.dialog 不是 Modal Popup JQuery 3.5.1 中的函数
【发布时间】:2021-04-19 19:47:38
【问题描述】:

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

我在控制台窗口中收到一条错误消息,上面写着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)

感谢您的帮助!

更新:

这是模态对话框扩展之一:

 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 });

    }

【问题讨论】:

    标签: javascript jquery jquery-plugins


    【解决方案1】:

    我遇到了同样的问题,对话框没有打开, 当我调试东西并发现哪个是我的 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);
        };
    

    【讨论】:

      猜你喜欢
      • 2021-08-24
      • 1970-01-01
      • 1970-01-01
      • 2020-03-30
      • 1970-01-01
      • 1970-01-01
      • 2022-12-01
      • 1970-01-01
      • 2015-05-09
      相关资源
      最近更新 更多