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. Mac PyCharm专业版破解

    1. 先在PyCharm官网:http://www.https://www.jetbrains.com/pycharm/,下载PyCharm专业版安装包 2. 安装PyCharm 3. 终端执行: s ...

  2. Quartz快速入门

    Quartz是一个定时任务调度的框架,在预定的时间到达时,执行某一任务 可认为是JDK的Timer类的扩展 Quartz的核心接口Scheduler – 核心调度器Job – 任务JobDetail ...

  3. iframe框架

    在一个页面里做一个区域引入另一个页面的方法: <a href="http://www.baidu.com" target="in">百度</a ...

  4. python面向对象总结

    一 面向对象的程序设计的由来 见概述:http://www.cnblogs.com/linhaifeng/articles/6428835.html 二 什么是面向对象的程序设计及为什么要有它 面向过 ...

  5. 基于Python实现的四则运算生成程序

    Github项目地址:传送门 小组成员:黄晓彬(代码实现) 黄钰城(代码审查) 需求: 1. 使用 -n 参数控制生成题目的个数. 2. 使用 -r 参数控制题目中数值(自然数.真分数和真分数分母)的 ...

  6. JAVA代码反编译笔记

    最近有个朋友说有个java弄的软件是从朋友处拿来的,由于进行了网卡地址绑定,不修改网卡地址无法使用,叫我看看有无办法破解,之前都很少玩这些东西,本着帮忙的心态,尝试了下,便有了一下的笔记内容. 1.使 ...

  7. 【python】import问题总结

    一.绝对引用 首先总结一下import的各种姿势: 1.import package 读这个包的__init__.py 2.import module 读这个模块全部内容 3.import packa ...

  8. 小晚wan的公众号

    转载请注明出处:http://blog.csdn.net/dongdong9223/article/details/70932630 本文出自[我是干勾鱼的博客] 小晚wan的公众号还是挺深刻的,有时 ...

  9. 软件测试 Record

    fxcopnunit软件质量 EDW 数据仓库ETL KPI 敏捷 测试计划 单元测试 集成测试 系统测试 对测试结果 阶段性 分析 总结 测试结果报告 环境问题:软硬件用户有问题,我们这边没有有效问 ...

  10. 【django】Bootstrap 安装和使用

    官网 下载:推荐下载源码包 安装Bower:使用Bower安装并管理 Bootstrap 的Less.CSS.JavaScript和字体文件(通过npm安装bower) npm install -g ...