Sticky toastr onclick event of close button

房东的猫 提交于 2020-01-16 01:36:08

问题


Is there a way I can perform an action after a user either clicks on the notification or clicks on the close button? At the moment I can do the first option using the options.onclick event. However I can not see how I can do this on the close button. Alternatively is there a way it could perform my action on the notification fading out?

toastr.options = {
    "closeButton": true,
    "timeOut": "0",
    "extendedTimeOut": "0"
};
toastr.options.onclick = function () {
    console.log("Notification clicked");
};
toastr.success("Success, Whooo!!");

回答1:


You can't do it nicely on click, because there is no callback. You could use a jquery live handler on the button.

About the notification after fading out, use this;

 toastr.options.onHidden = function() { console.log("onHide"); };


来源:https://stackoverflow.com/questions/20569865/sticky-toastr-onclick-event-of-close-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!