如何从Flask函数内部调用模态对话框 [英] How to call modal dialog from inside Flask function
问题描述
id =myModal
: < div id =myModalclass =modal faderole =dialog>
...
< / div>
我可以通过点击一个简单的< a>
。这是因为< a>
s data-target
属性链接到了模态对话框的 id
myModal
:
< a data-toggle =modaldata-target =#myModal>点击此处< / a>
我想知道是否有方法通过它的 id来调用这个模式对话框
@ app.route('/ call_modal',methods = ['GET','POST'])
def call_modal():
#...通过它的ID调用模态对话框?
您可以使用其他模式插件使其工作,如 Remodal 。与Bootstrap模式类似,每个模态都有一个id,你可以把它称为一个锚点,如下所示: // example.com#myModal
。
在你的view.py中:
@ app.route('/ call_modal',methods = ['GET','POST'])
pre>
def call_modal():
重定向(url_for('index')+'#myModal')
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>
sdata-target
attribute is linked to the modal dialog'sid
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?
解决方案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')
这篇关于如何从Flask函数内部调用模态对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!