0

我对这个脚本一头雾水,我无法让我的函数显示在 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;
            });

我通常不会在运行时收到消息,但是这样,但我相信我在某个地方很近:-)

4

1 回答 1

0

不确定您是否仍然遇到此问题,但我相信该alertify.alert函数没有任何回调,因为它只是显示消息的一种方式。您可能正在寻找alertify.confirm替代品。

该消息也没有显示,因为alertify.alertor的第一个参数alertify.confirm需要是一个字符串。在您的示例中,您正在传递一个对象。

我已经为您的代码设置了一个演示,该演示已被调整为在 JSFiddle 上工作。

值得一提的是,代码示例使用的是旧版本的 alertify (0.3) 并且已经更新,因此现在发布的版本 1语法会有所调整。

于 2015-09-16T10:24:29.467 回答