beforeClose not working in jGrowl?
Posted
by sparkymark75
on Stack Overflow
See other posts from Stack Overflow
or by sparkymark75
Published on 2010-04-09T23:30:47Z
Indexed on
2010/04/09
23:33 UTC
Read the original article
Hit count: 276
I have the following code which pulls json data from an ASP.NET page and displays these as notifications. The code will also take a note of what's been pulled through and store it in an array to prevent it being shown again in the same session.
I'm now trying to implement functionality so that when the user closes a message, it's ID is recorded in a cookie to prevent it ever being shown again. To do this, I'm trying to write to the cookie when the beforeClose event fires.
Everything else works fine apart from the saving to a cookie bit. Is there something wrong with my code that I'm missing?
var alreadyGrowled = new Array();
var noteCookie = $.cookie("notificationsViewed");
if (noteCookie != null) { alreadyGrowled = noteCookie.split(","); }
function growlCheckNew() {
$.getJSON('getNotifications.aspx', function(data) {
$(data).each(function(entryIndex, entry) {
var newMessage = true;
$(alreadyGrowled).each(function(index, msg_id) {
if (entry['ID'] == msg_id) {
newMessage = false;
}
});
if (newMessage == true) {
$.jGrowl(entry['Message'], {
sticky: true,
header: entry['Title'],
beforeClose: function(e, m) {
$.cookie("notificationsViewed", entry['ID']);
}
});
}
alreadyGrowled.push(entry['ID']);
});
});
}
© Stack Overflow or respective owner