首页 > 解决方案 > Bootbox 警报抛出“未捕获的 TypeError:div.on 不是函数”

问题描述

我使用 bootbox 向用户显示信息和决策消息,但他指责以下错误:“Uncaught TypeError: div.on is not a function”。有人可以帮我解决吗?

在我的代码下面:

<html>
    <script src="js/jquery/jquery-1.9.1.js" type="text/javascript"></script>
    <link rel="stylesheet" href="css/bootstrap.css"></link>
    <script language='javascript' type='text/javascript' src="js/bootstrap.js"></script>
    <script language='javascript' type='text/javascript' src="js/bootbox.js"></script>
    ...

    jQuery("#datagrid").navButtonAdd('#pdatagrid', {
      caption : '', title : 'Alerta', buttonicon : "ui-icon-link", onClickButton : function () {
        top.Base.getUtil().alerta('alerta acionado');
      }
    });

我的内部框架方法

alerta: function(message){
    bootbox.alert( message );
},

在 bootbox.js 中,错误“div.on is not a function”发生在第 409 行

    // hook into the modal's keyup trigger to check for the escape key
    div.on('keyup.dismiss.modal', function(e) {
        // any truthy value passed to onEscape will dismiss the dialog
        // as long as the onEscape function (if defined) doesn't prevent it
        if (e.which === 27 && options.onEscape) {
            onCancel('escape');
        }
    });

标签: javascriptjqueryhtmlbootbox

解决方案


推荐阅读