【问题标题】:javascript contents are not getting loaded,if i create a tab/contentPane dymaically with .xhtml as inputjavascript 内容未加载,如果我使用 .xhtml 作为输入动态创建选项卡/contentPane
【发布时间】:2013-04-25 12:19:48
【问题描述】:

我正在 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>

【问题讨论】:

    标签: xhtml dojo tabcontainer contentpane


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      虽然我不熟悉 dojo 工具包,但我认为您应该将 JavaScript 函数放在主文件中,或者像动态加载 JavaScript 一样; How do I include a JavaScript file in another JavaScript file?

      【讨论】:

        【解决方案3】:

        dijit.layout.ContentPane 将不支持 javascript,我的意思是它不会执行输入文件中的 javascript 内容。

        dojox.layout.ContentPane 是高级的,它将支持 javascript。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-10-08
          • 1970-01-01
          • 2020-07-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-07-16
          相关资源
          最近更新 更多