0

我正在 home.xhtml 文件中创建如下动态选项卡/内容窗格,我试图调用 order.xhtml 中存在的函数显示,它没有被调用。没有加载 order.xhtml 中的任何 java 脚本。

在 home.xhtml 中

    if(dijit.byId('ordersummary')!=null){
        dijit.byId('ordersummary').destroy();
        }
    newTab= new dijit.layout.ContentPane({
        id : 'ordersummary',
        title : 'Order Summary',
        href : 'order.xhtml',
        closable : true
    });
    dijit.byId('tabContainer').addChild(newTab);
     dijit.byId('tabContainer').selectChild(dijit.byId("ordersummary"));

javascript in order.xhtml

<script type="text/javascript">
    //<![CDATA[
    function display(){
      alert(" I M BEING CALLED");
             }
     </script>
4

3 回答 3

0

虽然我不熟悉 dojo 工具包,但我认为您应该将 JavaScript 函数放在主文件中,或者像动态加载 JavaScript 一样; 如何在另一个 JavaScript 文件中包含一个 JavaScript 文件?

于 2013-04-25T12:45:46.603 回答
0

有两种方法,一种是使脚本类型为 dojo/method。或者使用扩展的 dojox/layout/ContentPane。

http://livedocs.dojotoolkit.org/dijit/layout/ContentPane#executing-javascript-inside-contentpane

于 2013-04-25T13:55:58.977 回答
0

dijit.layout.ContentPane will not support javascript,i mean it will not execute the javascript content in the input file.

dojox.layout.ContentPane is advanced one and it will support javascript.

于 2013-04-26T09:37:04.553 回答