I'm trying to follow the flask documentation. After a successful form submission (a signup form), I flash a message saying 'Signup successful'. However, I'm trying to have this message appear on a bootstrap modal.
Simplified code is...
@app.route('/signup', methods=['GET','POST'])
def signup():
form = SignupForm()
if form.validate_on_submit():
flash('You were successfully signed up')
return render_template('signup.html', form=form)
Now I only need to trigger the modal with the success flash message if form submission is successful. So I had my modal HTML snippet inside the flash message checks.
<HTML code for forms>
<input type='submit' value="Signup" data-toggle="modal" data-target="#myModal">
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
{{ message }}
</div>
</div>
</div>
</div>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
This doesn't trigger the modal at all. Any thoughts on how I might get this to work?