I'm trying to create a notification with the css and div in this answer .
But I need more than one notification, so I serialized the ids of the divs.
Problem is, when I declare the click function, the variable nname
doesn't get evaluated - it's only evaluated when I click the dismiss button. So only last notification is dismissed.
How can I declare a function with the value of the variable 'nname'?
I found a similar post but it's about zsh.
nc = 0;
function show_notification(data){
nname = "notification_" + nc
$('body').append('<div id="' + nname + '" class="notification" style="display: none;"><span class="dismiss"><a title="dismiss notification">x</a></span></div>');
$('#' + nname).fadeIn("slow").append('some new information');
$('#' + nname + ' .dismiss').click(function(){$("#" + nname).fadeOut("slow");});
nc++;
}