Out of my frustration in wrapping Bootstrap alert / notification libraries to GWT I've decided to make one using GwtQuery:
public static void showErrorNotification(String message){
List<Widget> allNotifications = $(".notification").widgets();
for (Widget w : allNotifications){
$(w).fadeIn(1000);
$(w).append("<div id=\"errorAlert\" class=\"rounded10 errorAlert\">" +
"<img alt=\"\" src=\"public/images/exclamation.png\"> " +
"You must accept the terms and conditions to finish your registration." +
"</div>");
$(w).fadeOut(5000);
//$(w).empty();
}
}
The problem with this code is that, this method may be called by a user many times, and thus the append
'ed HTML will accumulate over time. empty'ing like in the commented line causes the notification to not even show up.
What could be the solution so that after it fades out, it will empty the notification panels?
Update:
When I put:
$(w).empty(
) before fadeIn()
nothing shows on the second time this method is called.