dojo动画不适用于xPage面板

时间:2016-12-15 05:10:40

标签: dojo xpages

我想擦拭我的面板。但它不适用于<xp:panel>组件,但适用于<div>。 这是我的代码:

<xp:panel id="myPanel">This is my panel</xp:panel>
.....
dojo.style("myPanel", "height", "");
dojo.style("myPanel", "display", "block");
var wipeArgs = {
        node: "myPanel"
    };
dojo.fx.wipeOut(wipeArgs).play();

这也不起作用:

dojo.style("#{id:myPanel}", "height", "");
dojo.style("#{id:myPanel}", "display", "block");
var wipeArgs = {
        node: "#{id:myPanel}"
    };
dojo.fx.wipeOut(wipeArgs).play();

但这确实有效:

<div id="myDiv">This is my DIV</div>
.....
dojo.style("myDiv", "height", "");
dojo.style("myDiv", "display", "block");
var wipeArgs = {
        node: "myDiv"
    };
dojo.fx.wipeOut(wipeArgs).play();

那么如何让它适用于xp:panel?

1 个答案:

答案 0 :(得分:1)

您需要在XSP.addOnLoad()调用中运行Dojo代码,以便Dojo使用XPages生成的ID。

<xp:scriptBlock id="scriptBlock1">
    <xp:this.value><![CDATA[
    XSP.addOnLoad(function(){
        dojo.style("#{id:myPanel}", "height", "");
        dojo.style("#{id:myPanel}", "display", "block");
        var wipeArgs = {
                node: "#{id:myPanel}"
            };
        dojo.fx.wipeOut(wipeArgs).play();
    });
]]></xp:this.value>
</xp:scriptBlock>

此外,如果您只想要一个div而不是一个附加了数据源的div,那么您可以使用xp:div代替xp:panel