【问题标题】:How to add event onClick in noty for notifications in jQuery?如何在 jQuery 通知的通知中添加事件 onClick?
【发布时间】:2015-02-08 21:31:21
【问题描述】:

我只想转到我的通知对象中的 URL 被单击(不是在它关闭时,只有当用户单击通知时)。我试过这个:

var n = noty({
    text: 'Nuevo Comentario: <br>' + data.contenido + ' de ' + data.usuario,
    layout: 'bottomRight',
    type: 'information',
    timeout: 3500,
    callback: { onClose: function() { /* Go to the URL i want to go */ }},
    animation: {
        open: {height: 'toggle'}, // jQuery animate function property object
        close: {height: 'toggle'}, // jQuery animate function property object
        easing: 'swing', // easing
        speed: 500 // opening & closing animation speed
    }
});

但即使事件自行关闭也会触发。如何查看用户点击通知的时间?

【问题讨论】:

  • 我在官方文档中没有看到 noty 提供的任何onClick 回调。您是否在通知元素上尝试过简单的.click()?这将触发标准onClose,当然,但它也会对你在.click() 中所做的任何事情做出反应。

标签: javascript jquery noty


【解决方案1】:

你可以试试这个技巧,它工作正常

           new Noty({
                layout: 'bottomRight',
                text: '<h6 onclick="clickOfDT()">_your text</h6>',
                type: 'warning',
                closeWith: ['button']
            }).show();

            clickOfDT=()=>{
                // HERE YOU GOT THE EVENT
            };

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-13
    相关资源
    最近更新 更多