Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call modal dialog from inside Flask function

Tags:

python

html

flask

With the Bootstrap modal dialog's id="myModal":

<div id="myModal" class="modal fade" role="dialog">
...
</div>

I can call it by clicking a simple <a>. It happens because <a>s data-target attribute is linked to the modal dialog's id myModal :

<a data-toggle="modal" data-target="#myModal">Click Here</a>

I wonder if there is a way to call this modal dialog by its id from inside of Flask python function.

@app.route('/call_modal', methods=['GET', 'POST'])
def call_modal():
    # ... call modal dialog by its id?
like image 359
alphanumeric Avatar asked Oct 18 '25 15:10

alphanumeric


1 Answers

You can use another modal plugin to make it work, such as Remodal. Similarly as Bootstrap modal, every modal has an id, you can call it as an anchor, like this: //example.com#myModal.

In your view.py:

@app.route('/call_modal', methods=['GET', 'POST'])
def call_modal():
    redirect(url_for('index') + '#myModal')
like image 161
Grey Li Avatar answered Oct 21 '25 04:10

Grey Li