如何从Flask函数内部调用模态对话框 [英] How to call modal dialog from inside Flask function

查看:549
本文介绍了如何从Flask函数内部调用模态对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用引导模式对话框的 id =myModal

 < div id =myModalclass =modal faderole =dialog> 
...
< / div>

我可以通过点击一个简单的< a> 。这是因为< a> s data-target 属性链接到了模态对话框的 id myModal

 < a data-toggle =modaldata-target =#myModal>点击此处< / a> 

我想知道是否有方法通过它的 id来调用这个模式对话框

来自Flask python函数里面。

  @ 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'])
def call_modal():
重定向(url_for('index')+'#myModal')
pre>

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?

解决方案

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆