popup功能
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功能的更多相关文章
- 可快速生成增删curd改查功能的插件
仿造Django中的admin自己实现增删改查.模糊搜索.批量操作.条件筛选.popup功能的插件 1.创建组件 首先创建一个app,这里取名为stark,在settings.py中将其进行注册 IN ...
- OpenLayers2中的事件_以Popup为例
SATURDAY, 21 MARCH 1-Preface 前几天阅读学习了OpenLayers'Cookbook中的第四章——Working with events. 从AFDS系统的开发项目进行至今 ...
- arcgis jsapi接口入门系列(9):可以同时显示多个的地图popup
jsapi有提供popup功能,但缺点很多,例如地图上只能同时显示一个popup,popup内容有限制等 本文提供另一个方法,原理不用jsapi,在地图外用一个普通的div放在地图上面,再监听地图的鼠 ...
- (转)OpenLayers3基础教程——OL3之Popup
http://blog.csdn.net/gisshixisheng/article/details/46794813 概述: 本节重点讲述OpenLayers3中Popup的调用时实现,OL3改用O ...
- OpenLayers3基础教程——OL3之Popup
概述: 本节重点讲述OpenLayers3中Popup的调用时实现,OL3改用Overlay取代OL2的Popup功能. 接口简单介绍: overlay跟ol.control.Control一样,是一 ...
- [WP8] 使用ApplicationMenu与使用者互动
[WP8] 使用ApplicationMenu与使用者互动 范例下载 范例程序代码:点此下载 功能说明 使用过Lumia系列手机的开发人员,对于内建的相机功能相信都很熟悉.在Lumia内建的相机功能中 ...
- Emacs安装auto-complete
分别下载各个el文件 auto-complete-mode 主源码库 https://github.com/auto-complete/auto-complete 把zip文件下载后,复制auto-c ...
- 【django之stark组件】
一.需求 仿照django的admin,开发自己的stark组件.实现类似数据库客户端的功能,对数据进行增删改查. 二.实现 1.在settings配置中分别注册这三个app # Applicatio ...
- django 之 stark组件
----------------------------------------------------------------烦恼没完没了,内心动荡不安,呜呼哀哉. 一.有个特殊的需求,需要用sta ...
随机推荐
- DOS命令说明
(转自:http://blog.csdn.net/mydriverc/article/details/2047152) 1 errorlevel dir cd md rd del ren cls ty ...
- 在Windows下为PHP5.6安装redis扩展
Redis 安装 Window 下安装 下载地址:https://github.com/MSOpenTech/redis/releases. Redis 支持 32 位和 64 位.这个需要根据你系统 ...
- react pagination
class AppPagination extends React.Component { handleChange(pageNum) { this.props.handleChangePage(pa ...
- windows 改路径有小差异
https://jingyan.baidu.com/article/5552ef473e2df6518ffbc916.html cmd是windows下一个非常常用的工具,但是它默认的地址却是不变的. ...
- Android Issue分析方法(用anr来说明)
Log的产生大家都知道 , 大家也都知道通过DDMS来看log , 但什么时候会产生log文件呢 ?一般在如下几种情况会产生log文件 . 1,程序异常退出 , uncaused exception ...
- 升级Tensorflow到1.2版本
TensorFlow 今天发布最新版 1.2.0,公布了14大最新功能.新智元带来最新介绍,包括 API 的重要变化.contrib API的变化和Bug 修复及其他改变.附代码链接. 主要的功能和改 ...
- [置顶]
Git 配置SSH简单玩法?
> 第一步下载git点击直接下载 他会检测您的系统当前是64bit还是32bit安装过程不再啰嗦反正就是Next Next Next Finish 第二步这里你可以下载TortoiseGit点击 ...
- ubuntu 上查看文件的内容,二进制形式展现
Vim 可以用来查看和编辑二进制文件 vim -b egenea-base.ko 加上-b参数,以二进制打开 然后输入命令 :%!xxd -g 1 切换到十六进制模式显示
- VC++6.0/MFC中如何限制Edit控件输入 例子,只能输入0和1
1.Insert -> New Class -> 在Base Class中选择CEdit,在Name中输入CMyEdit. 2.在左边的ClassView中,右键击CMyEdit,选择Ad ...
- 完全卸载session 所需要的函数
session_unset() 删除内存当中的session数据:必须放在session_destroy的前边.因为应用session_destory后session_id();就会消失. 删除se ...