0

我正在使用 pnotify 和加载回调函数来在 fullcalendar 插件加载所有事件时显示通知。

loading:function(isLoading, view){

    if (isLoading === false){
        new PNotify({
            title:"Finished loading events",
            type:'success',
            delay: 1000
        });

我的问题是,当我移动到不同的日期时,它会再次调用加载,所以我的屏幕上显示了如此多的通知,以至于它变得非常无法使用。我怎样才能绕过这个?有没有办法检查通知是否处于活动状态,只需更改它的文本和标题?

4

2 回答 2

0

您可以根据您使用的模板添加该逻辑(检查模板文档)。

您的代码将类似于

loading:function(isLoading, view){
    var exists = false;
    $(".ui-pnotify-title").each(function() {
        if ($(this).html() == 'Finished loading events')
            exists = true;
    });

    if (!exists) {
        new PNotify({
            title:"Finished loading events",
            type:'success',
            delay: 1000
        });
    }
}

如果您可以使用特定的 id 或类来检测通知是否已显示,那就更好了,但这很有效。

看看正在工作的 jsfiddle

于 2015-03-04T12:08:03.350 回答
0

您可以将其存储在一个变量中,执行必要的代码(如可空/未定义检查等)并调用“update()”(此处: http ://sciactive.com/pnotify/ - 例如,查找“单击”注意'并查看来源)

var p = new PNotify({
    title: 'Some title',
    text: 'Check me out! I\'m a error.',
    type: 'error',
    icon: 'fa fa-times-circle'          
});
// ... code ...
p.update({title: 'My new title'});
于 2015-06-26T22:41:44.770 回答