注意:可关闭"false"不工作

noty: closable "false" not working?

本文关键字:quot false 工作 注意      更新时间:2023-09-26

我正在使用" needdim noty" jquery通知插件,我试图仅以编程方式关闭通知,我看到选项closable停止关闭通知。但当我尝试通知关闭点击?

有什么想法停止关闭点击和编程吗?

" noty插件"

表示"可关闭"

我的问题

过去我需要这样的东西,我就是这样做的:

停止关闭点击,悬停和关闭按钮,我改变了模板和closeWith插件选项:

$.noty.defaults.closeWith = ["button"];
$.noty.defaults.template = '<div class="noty_message"><span class="noty_text"></span></div>';

这种方式noty将使所有通知关闭只有当点击模板关闭按钮,但由于我从模板中删除了它是不可能的。

请注意,您不需要将此设置为默认的注释行为。

以编程方式关闭它,我使用$.noty.close(id)$.noty. closeall ()函数。要使用第一个,您需要在创建它时生成的通知ID。您可以通过这种方式获取并存储它,以便在需要关闭特定通知时使用。

$n = noty({text: 'noty - a jquery notification library!'});
var noty_id = $n.options.id;

请参见下面的工作演示,以更好地理解

编辑:

要想动态地设置一些通知,你需要传递这样的选项:

var $n = noty({
    text: 'I have a special behaviour',
    template: '<div class="noty_message"><span class="noty_text"></span></div>',
    closeWith: ["button"]
});

请参见下面的工作演示,以更好地理解