簡體   English   中英

將函數傳遞給alertify.js

[英]Pass function to alertify.js

我對這個腳本不滿意,無法在Aletify.js警報中顯示我的功能。

一些幫助將非常有用;-)

功能:

        Oshoplang = { 
        // System Message Text
            RemoveError:        '<p>This item has now been removed from your cart.\n\nThank you.', 
            Added:              'Has now been added to your cart',
            OutOfStock:         '<p>This item is not currently available or is out of stock.</p>',
            PreOrder:           '<p>Your pre-order has been made successfully.\n\nThank you.</p>',
            InvalidQuantity:    '<p>It looks like you entered an invalid quantity.\n\nPlease try again.</p>',

        }

window.alert = function() {};

$("#confirm-else").on('click', function() {
                reset();
                $('#e-content').addClass('blur');
                alertify.alert(Oshoplang, function(e) {
                    if (e) {
                        alertify.success("OK");
                        $('#e-content').removeClass('blur');
                                                                                                            location.reload();
                    } else {
                        alertify.error("You've clicked Cancel");
                    }
                });
                return false;
            });

我通常不會在運行中收到任何消息,但是通過這種方式,但我相信我在某個地方很近:-)

不知道您是否仍然遇到此問題,但我相信alertify.alert函數沒有任何回調,因為這只是顯示消息的一種方式。 您可能正在尋找alertify.confirm

該消息也沒有顯示,因為alertify.alertalertify.confirm的第一個參數必須是字符串。 在您的示例中,您正在傳遞一個對象。

我已經為您的代碼建立了一個演示,已經對其進行了調整,可以在JSFiddle上使用

對於它的價值,代碼示例使用alertify(0.3)的舊版本,並已更新,從而使第1版是現在出將有一定程度調整語法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM