admin管理员组文章数量:1389783
I have flash message in my Flask app like this:
I want to if I click the close icon the flashed message is closing, or automatically closed in a set of time, eg: in 5 second it automatically closed.
Here is my _flash.html
{% macro render_flashes(class) %}
{% with msgs = get_flashed_messages(category_filter=[class]) %}
{% for msg in msgs %}
<div class="ui {{ class }} message">
<i class="close icon"></i>
{{ msg }}
</div>
{% endfor %}
{% endwith %}
{% endmacro %}
<div class="ui text container">
<div class="flashes">
{{ render_flashes('error') }}
{{ render_flashes('warning') }}
{{ render_flashes('info') }}
{{ render_flashes('success') }}
</div>
</div>
So what do I need to improve my code to do that..?
PS: for more information, I using this nicely boilerplate.
I have flash message in my Flask app like this:
I want to if I click the close icon the flashed message is closing, or automatically closed in a set of time, eg: in 5 second it automatically closed.
Here is my _flash.html
{% macro render_flashes(class) %}
{% with msgs = get_flashed_messages(category_filter=[class]) %}
{% for msg in msgs %}
<div class="ui {{ class }} message">
<i class="close icon"></i>
{{ msg }}
</div>
{% endfor %}
{% endwith %}
{% endmacro %}
<div class="ui text container">
<div class="flashes">
{{ render_flashes('error') }}
{{ render_flashes('warning') }}
{{ render_flashes('info') }}
{{ render_flashes('success') }}
</div>
</div>
So what do I need to improve my code to do that..?
PS: for more information, I using this nicely boilerplate.
Share Improve this question edited Aug 26, 2019 at 15:43 davidism 128k31 gold badges415 silver badges347 bronze badges asked Aug 26, 2019 at 15:07 TriTri 3,0596 gold badges41 silver badges73 bronze badges1 Answer
Reset to default 6You can do this with jQuery. Add an onclick function to the button like so:
<i class="close icon" onclick=delete_flash(this)></i>
And here's the code to delete:
<script src="https://ajax.googleapis./ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
function delete_flash(flash){
$(flash).parent().remove()
}
</script>
本文标签: javascriptFlask closing flash messageStack Overflow
版权声明:本文标题:javascript - Flask closing flash message - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744608804a2615524.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论