urls:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from django.conf.urls import url
from chapter01 import views urlpatterns=[
url('popupp',views.popparent),
url('popupr',views.realpopup,name="addgoup"),
url('double',views.doublepopup,name="doublepopup"),
]

views

from django.shortcuts import render
from django.shortcuts import HttpResponse
from chapter01 import models
# Create your views here. def popparent(request): usergroup_list=models.UserGroup.objects.all() return render(request, 'chapter01/usergroup_list.html', {'usergroup_list':usergroup_list}) def realpopup(request):
if request.method=="GET":
return render(request,'chapter01/add_usergroup.html')
else:
popupid=request.GET.get("popup")
if popupid:
title=request.POST.get("title")
obj=models.UserGroup.objects.create(title=title)
response={'data_dict':{'pk':obj.pk,'text':str(obj),'popid':popupid}} """
1.关闭popup页面
2.将新增数据添加,传送到到原来发送pop页面的 popid=ugID
""" return render(request,'chapter01/popup_response.html',response)
else:
title=request.POST.get("title")
models.UserGroup.objects.create(title=title)
return HttpResponse("重定向列表页面") def doublepopup(request):
if request.method=="GET":
return render(request,'chapter01/doublekill.html')

add_usergroup.html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>popuptest</title>
</head>
<body>
<form method="POST">
{% csrf_token %}
<input type="text" name="title"/>
<input type="submit" value="提交">
</form>
<a href="#" onclick="popupUrl('/chapter01/double/')">多级弹出</a> <script>
function popupUrl(url) {
window.open(url,'x2','status=1,width:300px,heigh:200px,toolbar=0,resizeable=1')
} function f1() {
alert(1111)
}
</script>
</body>
</html>

  


usergroup_list.html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>usergroup</title>
</head>
<body>
<p>用户名:<input type="text"></p> <p>用户组:
<select id="ugID">
{% for i in usergroup_list %}
<option value="{{ i.pk }}">{{ i.title }}</option>
{% endfor %}
</select>
<a onclick="popupUrl('/chapter01/popupr/?popup=ugID')">添加</a>
</p>
<script>
/*
*'xxxxx'是弹窗的别名,在出来的弹窗是将不是这个别名 而是会替换这个名字
* */
function popupUrl(url) {
window.open(url,'xxxxx','status=1,height:400,width:400,toolbar=0,resizeable=0')
} function popupCallBack1(data_dict) {
var tag=document.createElement("option");
tag.innerHTML=data_dict.text;
tag.setAttribute('value',data_dict.pk);
tag.setAttribute('selected','selected'); document.getElementById(data_dict.popid).appendChild(tag)
} function popupCallBack2() { }
</script> </body>
</html>

  

popup_response.html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>正在关闭的页面</title>
</head>
<body>
<script>
/*
opener谁发起的代指谁
*/
var data_dict={{ data_dict|safe }};
opener.popupCallBack1(data_dict);
window.close(); </script> </body>
</html>
doublekill.html

  

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
doublekilled
</body>
</html>

  

popup功能的更多相关文章

  1. 可快速生成增删curd改查功能的插件

    仿造Django中的admin自己实现增删改查.模糊搜索.批量操作.条件筛选.popup功能的插件 1.创建组件 首先创建一个app,这里取名为stark,在settings.py中将其进行注册 IN ...

  2. OpenLayers2中的事件_以Popup为例

    SATURDAY, 21 MARCH 1-Preface 前几天阅读学习了OpenLayers'Cookbook中的第四章——Working with events. 从AFDS系统的开发项目进行至今 ...

  3. arcgis jsapi接口入门系列(9):可以同时显示多个的地图popup

    jsapi有提供popup功能,但缺点很多,例如地图上只能同时显示一个popup,popup内容有限制等 本文提供另一个方法,原理不用jsapi,在地图外用一个普通的div放在地图上面,再监听地图的鼠 ...

  4. (转)OpenLayers3基础教程——OL3之Popup

    http://blog.csdn.net/gisshixisheng/article/details/46794813 概述: 本节重点讲述OpenLayers3中Popup的调用时实现,OL3改用O ...

  5. OpenLayers3基础教程——OL3之Popup

    概述: 本节重点讲述OpenLayers3中Popup的调用时实现,OL3改用Overlay取代OL2的Popup功能. 接口简单介绍: overlay跟ol.control.Control一样,是一 ...

  6. [WP8] 使用ApplicationMenu与使用者互动

    [WP8] 使用ApplicationMenu与使用者互动 范例下载 范例程序代码:点此下载 功能说明 使用过Lumia系列手机的开发人员,对于内建的相机功能相信都很熟悉.在Lumia内建的相机功能中 ...

  7. Emacs安装auto-complete

    分别下载各个el文件 auto-complete-mode 主源码库 https://github.com/auto-complete/auto-complete 把zip文件下载后,复制auto-c ...

  8. 【django之stark组件】

    一.需求 仿照django的admin,开发自己的stark组件.实现类似数据库客户端的功能,对数据进行增删改查. 二.实现 1.在settings配置中分别注册这三个app # Applicatio ...

  9. django 之 stark组件

    ----------------------------------------------------------------烦恼没完没了,内心动荡不安,呜呼哀哉. 一.有个特殊的需求,需要用sta ...

随机推荐

  1. 关键C函数备录

    一.搜索指定路径下的文件 (1) intptr_t _findfirst(const char *, struct _finddata_t *);//可以使用通配符*或? (2) int _findn ...

  2. 【OpenGL ES】关于VBO(Vertex Buffer Object)的一些坑——解析一些关于glBuffer的函数

    最近在写毕设的时候用到OpenGL ES中的VBO,由于对一些接口用到的变量不了解被坑得很惨,在此记录一下防止以后再被坑. 本文为大便一箩筐的原创内容,转载请注明出处,谢谢:http://www.cn ...

  3. ARM体系结构总结

    特殊功能寄存器与外设绑定,通用寄存器是与CPU绑定. ARM是RISC架构 常用ARM汇编指令只有二三十条 ARM是低功耗CPU ARM的架构非常适合单片机.嵌入式.尤其是物联网领域:而服务器等高性能 ...

  4. Cannot run program "svn" (in directory "G:\IntelliJ IDEA 2017.2.5"): CreateProcess error=2, 系统找不到指定的文件。

  5. Agilent RF fundamentals (7) Oscillator characterization

    ---------------------------------------------------------------------------------------------------- ...

  6. sql server显示行号

    --    工具-> --    选项-> --    文本编辑器-> --    所有语言-> --    常规-> --    显示-> --    行号

  7. 【SQL查询】合并多个数据集_union

    SQL UNION 操作符 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 SELECT 语句必须拥有相同数量的列.列也必须拥有相似的数据类型.同时,每 ...

  8. 第一章 Oracle10g数据库新特性

    1.1 Oracle10g数据库概述 1.1.1 网格数据库 Oracle10g数据库是一种为网格计算而设计的数据库,是第一个用完整集成的软件基础架构来实现网络计算的数据库系统,其中10g的g表示gr ...

  9. LeetCode Design TinyURL

    原题链接在这里:https://leetcode.com/problems/design-tinyurl/description/ 题目: How would you design a URL sho ...

  10. 浅谈CSRF跨站点请求

    CSRF是什么?      (Cross Site Request Forgery, 跨站域请求伪造)是一种网络的攻击方式,它在 2007 年曾被列为互联网 20 大安全隐患之一,也被称为“One C ...