Dojo..无法在内容窗格中执行javascript

发布于 2024-09-29 01:18:16 字数 1986 浏览 1 评论 0原文

我有一个独立的 html 页面,其中包含一个工作正常的 dojo DataGrid。我在下面添加了相关代码。


    <script type="text/javascript">
    var readStore, grid;
      var gridLayout = [
      new dojox.grid.cells.RowIndex({ name: "Row #", width: 5, styles: "text-align: left;" }),
      {
        name: "Name",
        field: "name",
        styles: "text-align:right;",
        width:30
      },
      {
        name: "Type",
        field: "type",
        width:20
      }
    ];
   function initGrid()
   {
     readStore=new dojox.data.QueryReadStore({url:"/EG3/orgUnit/getChildren",  requestMethod:"get"});
console.info("readStore initialized");

grid=new dojox.grid.DataGrid({store:readStore,
  id:"grid",
  delayScroll:true,
  structure:gridLayout,
  query:{id:2},
  loadingMessage:"Loading..."
}, document.createElement('div'));

dojo.byId("gridContainer").appendChild(grid.domNode);
grid.startup();
 }
  dojo.addOnLoad(initGrid);
</script>

</HEAD>
<BODY class="claro">
<div id="list" class="list">
  Table goes here
 <div id="gridContainer">
 </div>
</div>

现在,当我尝试将此页面作为内容窗格包含在 TabContainer 中时,就会出现问题。 TabContainer 按原样加载页面标记,并且不会触发包含网格的页面的 onLoad 脚本。

                  <div dojoType="dijit.layout.TabContainer" region="center" tabStrip="true" id="orgUnitTabs">
                <div dojoType="dojox.layout.ContentPane" title="Info" selected="true" id="orgInfo" jsId="orgInfo">

                </div>
                <div dojoType="dojox.layout.ContentPane" href="/EG3/app/orgUnit/orgUnitChildren.gsp" executeScripts="true" parseOnLoad="true" extractContent="true" title="Children" id="children" jsId="children">
                    Children of the selected Org
                    <script type="javascript" event="onLoad">
                     initGrid();
                    </script>
                </div>

关于如何触发子页面的 onLoad 脚本有什么想法吗?

提前致谢。

I have a standalone html page that contains a dojo DataGrid that works just fine. I am including the relevant code below.


    <script type="text/javascript">
    var readStore, grid;
      var gridLayout = [
      new dojox.grid.cells.RowIndex({ name: "Row #", width: 5, styles: "text-align: left;" }),
      {
        name: "Name",
        field: "name",
        styles: "text-align:right;",
        width:30
      },
      {
        name: "Type",
        field: "type",
        width:20
      }
    ];
   function initGrid()
   {
     readStore=new dojox.data.QueryReadStore({url:"/EG3/orgUnit/getChildren",  requestMethod:"get"});
console.info("readStore initialized");

grid=new dojox.grid.DataGrid({store:readStore,
  id:"grid",
  delayScroll:true,
  structure:gridLayout,
  query:{id:2},
  loadingMessage:"Loading..."
}, document.createElement('div'));

dojo.byId("gridContainer").appendChild(grid.domNode);
grid.startup();
 }
  dojo.addOnLoad(initGrid);
</script>

</HEAD>
<BODY class="claro">
<div id="list" class="list">
  Table goes here
 <div id="gridContainer">
 </div>
</div>

Now, the problem happens when I try to include this page as a contentpane within a TabContainer. The TabContainer loads the page markup as is and does not fire the onLoad script of the page that contains the grid.

                  <div dojoType="dijit.layout.TabContainer" region="center" tabStrip="true" id="orgUnitTabs">
                <div dojoType="dojox.layout.ContentPane" title="Info" selected="true" id="orgInfo" jsId="orgInfo">

                </div>
                <div dojoType="dojox.layout.ContentPane" href="/EG3/app/orgUnit/orgUnitChildren.gsp" executeScripts="true" parseOnLoad="true" extractContent="true" title="Children" id="children" jsId="children">
                    Children of the selected Org
                    <script type="javascript" event="onLoad">
                     initGrid();
                    </script>
                </div>

Any ideas on how the onLoad script of the child page can be fired?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七婞 2024-10-06 01:18:16

你应该检查参数executeScripts是否设置为TRUE,如果你想使用声明性方法,你必须手动解析domNode,详细的dojo.parse方法:http ://docs.dojocampus.org/dojo/parser

you should check if the param executeScripts set to TRUE, and if you wanna use declarative method, you have to parse the domNode manually, see the detailed dojo.parse method:http://docs.dojocampus.org/dojo/parser

沐歌 2024-10-06 01:18:16

不确定正确的答案是什么,但如果我是你,我会尝试以编程方式而不是声明方式完成这一切,捕获错误,使用控制台输出查看正在发生的情况并在加载时记录事件。

Not sure what the right answer is, but if I were you, I would try doing it all programatically instead of declaratively, trap errors, use console outputs to see what's happening and log events as it loads.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文