<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE html>
<html>
<head>
<%@include file="../assets/header-all.jsp"%>
</head>
<body class="easyui-layout">
     <a href="javascript:opendialog();" class="easyui-linkbutton" >弹框</a> 
</body>
<script type="text/javascript">

var  windowid ; //全局定义。
function opendialog(){
	var sysUrl = "http://"+top.window.location.host+"/"+window.location.pathname.split("/")[1];
	windowid = top.$.createWin({
		 title	: 	'弹框标题',
		 width	:  	520,
		 height	: 	420,
		 onClose:   onclose, 
		 
		 //把参数当做属性,具体的页面具体取
		 data	:  [{loginName:"admin",userName:"admin",email:"email"}],
		 param	:  "abcdefg",
		 
		 //url	:	top.sysUrl+"/frame/demo/pages/formdemo.jsp",
		 url	:	sysUrl+"/frame/demo/pages/formdemo.jsp",
		 
		 //buttons 默认已经包含了关闭按钮，并能响应onClose事件方法
		 buttons: [{
			 text:$.fn.textbox.defaults.ok,
			 handler:getFormValueById
         }]
	 });
}
function onclose(){
	alert("关闭窗口之后执行的函数")
};

function getTopWindowById(wid){
	var frame 	= top.$("#"+wid).children("iframe")[0];
	return (frame.contentWindow||frame.window);
}

function dosure(){
	var win		=	$.getTopWindowById(windowid);
	var jq		=	win.$;
	var loginName	=	jq('#loginName1').textbox("getValue");
	var userName	=	jq('#userName1').textbox("getValue");
	console.log(jq('#loginName1').attr("class"));
	
	//console.log("loginName:"+loginName+" --- " + "userName"+userName)
}
function getFormValueById(windowId,contentFormId,ignoreIdsArray){
	//例:弹出页面中指定的iframe url为:top.sysUrl+"/frame/demo/pages/formdemo.jsp".
	//在弹出页面dormdemo.jsp中的自定义的表单id为 ：myform .
	//通过弹出页面ID(windowid ) 和指定的表单ID(myform),返回表单内所有的input 和select对象 和它们对应的值.
	//目前仅支持的文本框类型为：'easyui-textbox','easyui-combobox',"easyui-datebox","easyui-datetimespinner","easyui-timespinner","easyui-searchbox"
	//若想设定某元素不自动取值，添加 autoGet = 'false'即可.
	//参见 jquery-util.js 的getFormValueObject方法，欢迎批评指正..
	var valueObject = $.getFormValues("myform",windowid);
	console.log(valueObject);
	console.log("---------");
	var win		=	$.getTopWindowById(windowid);
	var jq		=	win.$;
	console.log(jq("#switchbutton1").switchbutton("options"));
}

</script>
</html>