javascript 弹出窗口中的 Django 渲染模板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9063831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 05:29:17  来源:igfitidea点击:

Django render template in a pop-up

javascriptdjangopopup

提问by ScotchAndSoda

As a beginer with javascript, I am looking for a manner to render a template from django in a javascript popup. Thanks.

作为 javascript 的初学者,我正在寻找一种在 javascript 弹出窗口中从 django 呈现模板的方法。谢谢。

回答by Mohammad Efazati

create view and django template and in django template create link to new page

创建视图和 django 模板,并在 django 模板中创建指向新页面的链接

<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
    newwindow=window.open(url,'{{title}}','height=200,width=150');
    if (window.focus) {newwindow.focus()}
    return false;
}

// -->
</script>

<a href="popupex.html" onclick="return popitup('/example/popup')"
    >{% trans 'Link to popup' %}</a>

so you must have another app with '/example/popup'url

所以你必须有另一个带有'/example/popup'url 的应用程序

ps: there are many other way ... its only one suggestion!

ps:还有很多其他的方式......它只有一个建议!