easyui dialog 父页面与子页面取值

-----------------父页面-------------------

//url:窗口调用地址,title:窗口标题,width:宽度,height:高度,shadow:是否显示背景阴影罩层

function showMessageDialog(url,id, title, width, height, shadow) {

var content = '<iframe src="' + url + '" width="100%" height="99%" frameborder="0" scrolling="no"></iframe>';

var boarddiv = '<div id="'+id+'" title="' + title + '"></div>'//style="overflow:hidden;"可以去掉滚动条

$(document.body).append(boarddiv);

var win = $('#'+id).dialog({

content: content,

width: width,

height: height,

modal: shadow,

title: title,

onClose: function () {

$(this).dialog('destroy');//后面可以关闭后的事件

},

buttons:[{

text:"确定",

handler:function(){

                                      //调用子页面easyui dialog 

window.top.reload_dataList.call();

$("#"+id).dialog("close");

}

},{

text:"取消",

handler:function(){

$("#"+id).dialog("close");

}

}]

});

win.dialog('open');

}

--------------------子页面--------------

window.top["reload_dataList"]=function(){

var rows = $('#dataGrid').datagrid('getSelections');

var listname='';

var id='';

for(var i=0; i<rows.length; i++){

id=rows[i].id;

listname=rows[i].listname;

}

      //向父页面传值

$(window.parent.$("#datalistId").val(id));

$(window.parent.$("#datalistName").val(listname));

console.log("id:"+id+"listname:"+listname)

};

猜你喜欢

转载自pxy.iteye.com/blog/2393899