I'm trying to build my own message prompt, error, warning etc. plugin, but I would like to allow the messages to queue.
The way I've done it was to include a single modal in my html (this way I can also include there standard names for type of message like 'Error', 'Warning' or their translation using JSTL) and call it using:
function message(messageText, messageType) {
$('#message').text(messageText);
$('#messageIcon').removeClass();
if (messageType == messageTypes.ERROR) {
$('#messageIcon').addClass("glyphicon glyphicon-remove-circle text-danger");
$('#messageHeader').text($(" " + '#ERROR').text());
} else if (messageType == messageTypes.WARNING) {
$('#messageIcon').addClass("glyphicon glyphicon-warning-sign text-warning");
$('#messageHeader').text(" " + $('#WARNING').text());
} else if (messageType == messageTypes.INFO) {
$('#messageIcon').addClass("glyphicon glyphicon-info-sign text-primary");
$('#messageHeader').text(" " + $('#INFO').text());
}
$('#messageModal').modal();
}
But this allows only to change the modal while its still being displayed, so it results in only the last message being shown. I've tried wrapping the code of that function in:
$('#messageModal').on('hidden.bs.modal', function (e) {
//above code
}
I thought it was logical to only fire the function if modal is being in its hidden state... but that doesn't work. Is there any way to fix it or am I going the wrong way to do this?