【问题标题】:jGrowl how to close notifcation?jGrowl如何关闭通知?
【发布时间】:2014-07-25 07:39:54
【问题描述】:

在我的 jgrowl 消息中,您要求回答是或否,两者都运行 ajax 调用,成功后我希望关闭通知,我该怎么做,是否有一条线可以关闭,因为现在他们所有人都在计时器(生命)上,所以如果我不让它们“粘住”,它们就会自行关闭

【问题讨论】:

  • 现在已经很晚了,但是根据您正在进行的 ajax 调用的性质,如果您有任何方法将调用者上下文与响应处理程序相关联,那么做起来并不难。

标签: jquery jquery-plugins jgrowl


【解决方案1】:

根据您正在进行的 ajax 调用的性质,如果您有任何方法将调用者上下文与响应处理程序相关联,那么做到这一点并不难。

确实,如果您没有标识符,您可以“创建它”(即作为 GUID)并在回调函数中使用它。

即使用 jQuery AJAX

var myId=this.id;
$.ajax{
(...),
success:function(){
 alert(myId);//still visible from within this place
},
(...)
}

如果您将此标识符添加到 jGrowl 面板(可能是隐藏的),那应该足够了。

现在,我在小提琴中添加了我过去使用过的东西的修改代码,以防万一它被删除,我也会把它留在这里。这是小提琴网址:http://jsfiddle.net/MCNUw/12/

html

<html>
<body>
    Open
    <div class="classOpen" source="d1">
        div1
    </div>
    <div class="classOpen" source="d2">
        div2
    </div>
    &nbsp;<br>
    Close
    <div class="classClose" source="d1">
        div1
    </div>
    <div class="classClose" source="d2">
        div2
    </div>

</body>

css

.classOpen{color:green;}
.classClose{color:red;}

js

var jGrowlConstraints=
{
    jGrowlNotifSelector:'.jGrowl-notification',
    jGrowlCloseThickSelector:'.jGrowl-close'
}

$(".classOpen").click(
    function(){
        var $domElement=$(this);
        $.jGrowl("<span source='"+$domElement.attr("source")+"'/>"+$domElement.html()
                 ,{ sticky: true });        
    }
);

$(".classClose").click(
    function(){
        var $domElement=$(this);
        $(jGrowlConstraints.jGrowlNotifSelector)
        .has("[source="+$domElement.attr("source")+"]")
        .find(jGrowlConstraints.jGrowlCloseThickSelector)
        .click();
    }
);

希望我能早点看到你的问题来帮助你

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-18
    • 1970-01-01
    • 2014-05-10
    • 1970-01-01
    • 2014-12-10
    • 2011-02-21
    • 1970-01-01
    相关资源
    最近更新 更多