100分,关于easyui dialog 使用href来加载远程页面,子页面的初始化有关问题,有简单异常demo

100分,关于easyui dialog 使用href来加载远程页面,子页面的初始化问题,有简单错误demo
母页面:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic Dialog - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  <script type="text/javascript">
function opendlg()
{

            $('#dlg').dialog({    
                title: '合并',   
                width: "80%",  
                height: 600,    
                closed: true,    
                cache: false,    
                href: 'child.html',    
                modal: false,
           
                onLoad: init_merge_dialog()
            });
            console.log("11");
            $("#dlg").dialog("open");
            console.log("22");
}


function init_merge_dialog()
{

     console.log("1");
            //$.parser.parse('#tb_merge');

            $('#txtInStockTime11').datebox('setValue', '2015-09-01');

}

</script>
</head>
<body>
<h2>Basic Dialog</h2>
<p>Click below button to open or close dialog.</p>
<div style="margin:20px 0;">
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="opendlg()">Open</a>
</div>
<div id="dlg" ></div>
</body>
</html>


子页面:


<div id="tb_merge" style="padding: 5px 0">
    <input id="txtInStockTime11" name="txtInStockTime11" class="easyui-datebox" />
</div>



母页面的功能就是弹出一个dialog,这个dialog的href就是child.html

现在的程序的样子是这样的:
100分,关于easyui dialog 使用href来加载远程页面,子页面的初始化有关问题,有简单异常demo

OnLoad中的代码执行了,但是没有在界面上显示出来日期,请问是那里的问题呢?


这个问题纠结了一天了,一直没找到好的方法解决
------解决思路----------------------
不好意思,这个easyui我没用过。
也许你可以尝试在child.html上添加比如onload之类的操作。
------解决思路----------------------
需要等待加载完成并生成DOM时才可以赋值,用循环是正确的。并且在cache=false时重新打开对话框时需要再次赋值,这块需要处理

<script type="text/javascript">
function opendlg()
{
  $('#dlg').dialog({    
title: '合并',   
width: 580,  
height: 200,    
closed: true,    
cache: false,    
href: 'child.html',    
modal: false,

onLoad: function(){
//alert('Fires when remote data is loaded.');
init_merge_dialog(0);
},
onOpen:function(){
//alert('Fires after panel is opened.');
},
onBeforeOpen:function(){
//alert('Fires before panel is opened, return false to stop the open.');
//如果不清除,重新打开对话框时不能赋值(cache=false时)
document.getElementById('dlg').innerHTML='';
}
});
$("#dlg").dialog("open");
}
function init_merge_dialog(n)
{
//需要等待加载并生成DOM后才执行赋值
if(document.getElementById('txtInStockTime11')){
$('#txtInStockTime11').datebox('setValue', '9/1/2015');
}else{
//控制循环次数,避免加载错误时死循环
if(n<5){
n++;
setTimeout('init_merge_dialog('+n+')',200); //重复调用
}
}
}
</script>