javascript - How to share a dojo widget to the child window which was created by window.open? -
i created widget in parent window , create sub window using window.open
. want display widget in sub window without using new.
we have tried use public variable pass it, when display it, there undefined
error!
//the public variable remember widget create parent window common.testpage = null; //the parent window this.wfrmstatistics = new dijit.layout.contentpane({ region : "center", style : "width: 100%;height: 100%;" }); this.mainstack.addchild(this.wfrmstatistics); this.mainstack.selectchild(this.wfrmstatistics); //new widget common.testpage = new gadd.wfrmstatistics({ style : "width:100%;height:100%;" }); this.wfrmstatistics.setcontent(common.testpage.domnode); common.testpage.startup(); //the sub window(actually same js file parent window),create window.open this.wfrmstatistics = new dijit.layout.contentpane({ region : "center", style : "width: 100%;height: 100%;" }); this.mainstack.addchild(this.wfrmstatistics); this.mainstack.selectchild(this.wfrmstatistics); this.wfrmstatistics.setcontent(window.opener.common.testpage.domnode); //cause undefined error on web page
i'm not sure if understand enough, assume mean have parent page dojo widget on it, , want access same widget instance on child page?
then indeed have define in global variable (because have attach window
). example:
require([ "dijit/form/button" ], function(button) { window.mybtn = new button({ label: "click me" }, "mynode"); });
then should able access in child window using:
window.opener.mybtn;
but must it's pretty ugly solution, don't think parent/child windows commonly used , global scope should avoided as possible well.
Comments
Post a Comment