Toastr CloseClick事件即使未单击也被触发

时间:2018-06-26 08:13:43

标签: toastr

我在Toastr 2.1.1中有一个奇怪的行为,发生的事情是即使我没有单击它,当工具提示出现时也会触发CloseClick事件

以下是我的代码(对无用的询问有些遗漏)

script type="text/javascript">

function onCloseClick(e) {
    var url = '<%=Url.Action("Index","Import",new {id = "-1"})%>';

    url = url.replace("-1", e.RequestId);

    window.open(url, "target=_blank");
}

function InitSignalR() {
    try {
        $(function () {

            var timeout = 5;
            // Reference the auto-generated proxy for the hub.
            var chat = $.connection.notificationHub;

            chat.client.updateNotifications = function (message) {

                var obj = JSON.parse(message);

                var notify = function (level) {

                    toastr.options.fadeOut = timeout * 1000;
                    toastr.options.onCloseClick = onCloseClick(obj);
                    var func;
                    switch (level) {
                        case "success":
                            func = toastr.success;
                            break;

                        case "error":
                            func = toastr.error;
                            break;

                        case "warn":
                            func = toastr.warning;
                            break;
                        case "info":
                            func = toastr.info;
                            break;
                    }
                    func(msg);
                } 
[omiss]
</script>

我在做什么错了?

0 个答案:

没有答案