我只想转到我的noty对象中的一个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
}
});
但是该事件即使在其自身关闭时也会被触发。如何检查用户何时单击通知?
你可以尝试这个破解方法,它可以很好地进行
new Noty({
layout: 'bottomRight',
text: '<h6 onclick="clickOfDT()">_your text</h6>',
type: 'warning',
closeWith: ['button']
}).show();
clickOfDT=()=>{
// HERE YOU GOT THE EVENT
};