开发者

jGrowl how to close notifcation?

In my jgrowl message, your asked to answer either Yes or No, both runs a ajax call, and on success i wish to close the notification, how can i do that, is there a line to close, because right now they all are on timers(life), so they c开发者_Python百科lose themselves if i dont make them "sticked"


Depending of the nature of the ajax call you are making, if you had any way to relate the caller context to the response handler, it wouldn't be that hard to do.

Indeed if you do not have an identifier you could 'create it' (i.e. as a GUID) and use it within the callback function.

i.e. using jQuery AJAX

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

If you add this identifier to the jGrowl panel (hidden perhaps), that should be enought to do the trick.

Now, I added in a fiddle the modified code of something I've used in the past, just in case it get's erased, I'll leave it here too. This is the fiddle url: 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();
    }
);

wish I would have seen your question earlier to help you then

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜