Modifications in the project bug colleagues found incompatible on IE11, will display an error js like, delete an element, the result is deleted together more, because the reference can not find the address.
Before code
Save time trigger sub-pages, find the form of the parent page content
1 function save(){ 2 var productEditPage = $(parent.document).contents().find("#layui-layer-iframe" + parent.layerIndex)[0].contentWindow; 3 var selections = getAllSelections(); 4 $(selections).each(function (index, e) { 5 productEditPage.productSchemeData.productSchemeBom.push(e); //父页面的对象 6 }); 7 productEditPage.loadBom(); 8 delete parent.layerIndex; 9 var index = parent.layer.getFrameIndex(window.name); 10 parent.layer.close(index); 11 }
Remove subform assignment data in parent form productSchemeData.productSchemeBom, the results has been given on the IEs, since subpages closed, corresponding references are also closed, corresponding references found in the parent page
I debugged this pit one morning to find a lot of posts on the Internet, did not find more appropriate, then be communicated to think of as a form of argument, if the data is deleted, the data before deleting a deep copy, it will not appear the original reference addresses the problem does not exist
Solution:
1 function save(){ 2 var productEditPage = $(parent.document).contents().find("#layui-layer-iframe" + parent.layerIndex)[0].contentWindow; 3 var selections = getAllSelections(); 4 var productAdd =new Array(); 5 $(selections).each(function (index, e) { 6 //productEditPage.productSchemeData.productSchemeBom.push(e); 7 productAdd.push(e); 8 }); 9 productEditPage.loadBom(productAdd); 10 delete parent.layerIndex; 11 var index = parent.layer.getFrameIndex(window.name); 12 parent.layer.close(index); 13 }
In an array of sub-page new, assigned, passed as a parameter to the parent page
var productAdd =new Array();
$(selections).each(function (index, e) {
productAdd.push(e);
});
productEditPage.loadBom(productAdd);
Its deep copy or delete related operations in the parent page
1 function loadBom(productAdd) { 2 if(productAdd!=undefined&&productAdd!=null&&productAdd!=""&&productAdd.length>0) 3 { 4 var newArray=new Array(); 5 if(productSchemeData.productSchemeBom!=null&&productSchemeData.productSchemeBom.length>0) 6 { 7 newArray=productSchemeData.productSchemeBom.concat(productAdd); //数组拼接 8 productSchemeData.productSchemeBom= $.extend(true,[],newArray); //深拷贝 9 } 10 else 11 { 12 productSchemeData.productSchemeBom= $.extend(true,[],productAdd); //深拷贝 13 } 14 } 15 ………………
, Data deep copy, whatever you how to delete is not being given.