Oly*_*ova 1 html javascript django jquery django-views
我有一个提交表单,提交时正在做一些复杂的过程,然后在django视图中我有这个:
return redirect('match:finding', ...)
Run Code Online (Sandbox Code Playgroud)
我可以在视图中添加一些内容来使重定向不在完成提交表单的页面上,而是在新标签页中进行吗?就像,将选项卡保持原样,然后打开一个新窗口以继续该过程。
在html模板中,它看起来像这样:
<div class="form-input">
<input id="app-submit" type="submit" value="{% if credit_card %}Get Started{% else %}Loan{% endif %}"/>
</div>
Run Code Online (Sandbox Code Playgroud)
我不能只添加带有target =“ _ blank”或window.open('url','new window')的/ span标签,因为实际单击提交按钮后将生成url。
小智 6
target="_blank"在您的form[1]中添加一个属性。由于您正在重定向,因此提交后是否生成url无关紧要。
安装示例如下所示:
- views.py
def ex_form_view(request):
...
return redirect('...', ...)
Run Code Online (Sandbox Code Playgroud)
- urls.py
url(r'^ex_form', views.ex_form_view, name='example')
Run Code Online (Sandbox Code Playgroud)
- template.html
<form action="ex_form" target="_blank">
<input id="app-submit" type="submit" value="{% if credit_card %}Get Started{% else %}Loan{% endif %}"/>
</form>
Run Code Online (Sandbox Code Playgroud)
[1] https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/form#Attributes
| 归档时间: |
|
| 查看次数: |
4346 次 |
| 最近记录: |