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 ...
随机推荐
- 关于Java类
一个.java文件中可以有很多类.不过注意以下几点: 1.public 权限的类只能有一个(也可以一个都没有,但最多只有1个) 2.这个.java文件的文件名必须是public类的类名(一般的情况下, ...
- opencv:直方图操作
示例程序: #include <opencv.hpp> using namespace cv; using namespace std; int main() { Mat src, dst ...
- webpack2配置
详细的配置可以参考官网:https://doc.webpack-china.org/guides/ 一开始做项目时都是直接从组里前辈搭建好的脚手架开始写代码,到后来自己写新项目时又是拷贝之前的工程作为 ...
- Agilent RF fundamentals (11)-Vector modulator
Vector modulator 矢量调制器:调整信号的幅度和相位 http://www.21ic.com/app/test/201805/762401.htm
- java svnkit实现svn提交,更新等操作
官网:https://svnkit.com/ api:https://svnkit.com/javadoc/org/tmatesoft/svn/core/io/SVNRepository.html w ...
- lua基础---函数
Lua的函数功能很强大,保留了C语言的一些基本的特性,但是也有C语言没有的特性,比如,lua可以在一个函数返回多个值,我们来看看下面这个案例: 解释运行: lua test5.lua --定义一个函数 ...
- Leetcode 867. Transpose Matrix
class Solution: def transpose(self, A: List[List[int]]) -> List[List[int]]: return [list(i) for i ...
- 推荐使用typora
最近在网上接触到一款全新的markdown写作工具--typora. 现在它已经是我的主要写作工具了. 甚至我也也会利用它安排自己的工作和任务. typora介绍 下载链接 特色:可以即时渲染mark ...
- Oracle临时表和SQL Server临时表的不同点对比
文章来源:http://www.codesky.net/article/201109/141401.html 1.简介 Oracle数据库除了可以保存永久表外,还可以建立临时表temporary ta ...
- 转载FPGA学习之内嵌乘法器调用
补充一点,除法的时候如果直接a/b那么就会调用lpm模块,不管输入是否是常数,乘法的时候输入都是reg型变量会调用硬件乘法器,有一个是常数就会调用lpm模块. 上课的时候一直听老师说真正实践的时候你别 ...