{%- with messages = get_flashed_messages(with_categories=true) -%}
{% if messages %}
<div style="position: fixed; top: 20px; right: 20px; width: 400px; z-index: 9999">
    {% for category, message in messages %}
    <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
        {{ message }}
        <button onclick="hide()" type="button" class="close" data-dismiss="alert" aria-label="{{ _('Close') }}"><span
                aria-hidden="true">&times;</span></button>
    </div>
    {% endfor %}
</div>
<script>
function hide(){
    var target = event.target || event.srcElement;
    if (target.type === undefined)
        target=target.parentNode;
    target.parentNode.classList.remove("show");
}
</script>
{% endif %}
{%- endwith %}
