Notifications work through page-reload / page-redirect

- Uses session storage
This commit is contained in:
Oliver 2018-04-29 23:47:16 +10:00
parent b6665ec2a7
commit e62bf92bd6
3 changed files with 33 additions and 0 deletions

View File

@ -5,4 +5,33 @@ function showAlert(target, message, timeout=5000) {
$(target).delay(timeout).slideUp(200, function() {
$(this).alert(close);
});
}
function showCachedAlerts() {
// Success Message
if (sessionStorage.getItem("alert-success")) {
showAlert("#alert-success", sessionStorage.getItem("alert-success"));
sessionStorage.removeItem("alert-success");
}
// Info Message
if (sessionStorage.getItem("alert-info")) {
showAlert("#alert-info", sessionStorage.getItem("alert-info"));
sessionStorage.removeItem("alert-info");
}
// Warning Message
if (sessionStorage.getItem("alert-warning")) {
showAlert("#alert-warning", sessionStorage.getItem("alert-warning"));
sessionStorage.removeItem("alert-warning");
}
// Danger Message
if (sessionStorage.getItem("alert-danger")) {
showAlert("#alert-danger", sessionStorage.getItem("alert-danger"));
sessionStorage.removeItem("alert-danger");
}
sessionStorage.setItem("alert-danger", 'test');
}

View File

@ -76,6 +76,8 @@ $(document).ready(function () {
{% endblock %}
showCachedAlerts();
});
</script>

View File

@ -1,3 +1,4 @@
<div class='notification-area'>
<div class="alert alert-success alert-dismissable" id="alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Success alert</div>
@ -14,3 +15,4 @@
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<div class='alert-msg'>Danger alert</div>
</div>
</div>