I use this piece of JavaScript/jQuery which I have in my base.html. I\'m using Flask(or jinja) for template inheritance and when a error is flashed this section will reopen