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. YCSB benchmark测试cassandra性能——和web服务器测试性能结果类似

    转自:http://www.itdadao.com/articles/c15a531189p0.html http://www.cnblogs.com/bettersky/p/6158172.html ...

  2. ARM汇编指令集4

    协处理器cp15操作指令: mcr & mrc •mrc用于读取CP15中的寄存器 •mcr用于写入CP15中的寄存器   什么是协处理器? •SoC内部另一处理核心,协助主CPU实现某些功能 ...

  3. shell与正则表达式

    作业一:整理正则表达式博客 已整理完.作业二:grep作业(正则表达式及字符处理) 目标文件/etc/passwd,使用grep命令或egrep 1.显示出所有含有root的行:[root@bogon ...

  4. 开源项目Universal Image Loader for Android 说明文档 (1) 简介

     When developing applications for Android, one often facesthe problem of displaying some graphical ...

  5. Azure Sql Database为某个数据库创建单独的访问账户

    由于SQL Management Studio对Azure SQL Database支持不完美,不能使用图形界面,因此配置数据库就会有不同的麻烦,下面是本人配置访问账户的一些经验: 1.以管理员登陆之 ...

  6. Raspberry Pi 配置

    资料 教程 <树莓派使用指南> 系统盘制作 插上电源,连上HDML线,计科

  7. 转载:将STM32的标准库编译成lib使用【图文】

    from:http://www.cnblogs.com/zyqgold/p/3189719.html 百度上边也有不少关于lib文件的文章,恰巧看到该博文,感觉该博文的条理清晰,步骤明确,故复制到这个 ...

  8. 解决 Laravel/Lumen 出现 "Please provide a valid cache path" 问题

    解决 Laravel/Lumen 出现 "Please provide a valid cache path" 问题 解决 Laravel/Lumen 出现 "Pleas ...

  9. HTML里 iframe跳转后关闭iframe

    if(window != top){      top.location.href = location.href;    }

  10. 【ACM非算法部分】scanf()函数

    scanf函数 格式说明符: %c    字符型 %d    十进制数 %i     读入十进制,八进制,十六进制数.输入的时候正常是十进制数,若输入0前缀的数将读入八进制,0x前缀读入16进制.若输 ...