如何将回调添加到jquery插件函数

时间:2016-12-21 10:36:59

标签: jquery jquery-plugins jquery-callback

我正在使用jquery插件进行以下警报: -

 function alertWithNewWindow(title, content, icon, newWindow) {
            $.alert.open({
                title: title,
                content: content,                   
                icon: icon,                   
                draggable: true
            });
        }

我想在上面的函数中添加一个回调,这样当用户点击" ok" alert-box按钮然后页面将重定向到给定路径。

  $(window.location.replace(newWindow));

我尝试了下面的代码,但它没有重定向。

   function alertWithNewWindow(title, content, icon, newWindow) {
            $.alert.open({
                title: title,
                content: content,                
                icon: icon,                  
                draggable: true
            }, function () {
                $(window.location.replace(newWindow));
            }
            );
        }

1 个答案:

答案 0 :(得分:1)

我猜您正在使用this plugin

阅读回调文档部分后,我认为此代码应该适合您:

main = readEncryptedZip "protected_file2.zip" "ll" >>= writeZip "unprotected.zip"
相关问题