Outline 中的 Onclick 事件在页面打开时执行 [英] Onclick event in Outline gets executed on page open

查看:27
本文介绍了Outline 中的 Onclick 事件在页面打开时执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个扩展库大纲控件.我在大纲中有两个 basicLeafNode.每个节点上的 onclick 事件都应该运行一些代码.问题是这两个 onClick 事件在页面打开时都在执行,但在您实际单击节点时似乎没有执行.

I have an extension library outline control. I have two basicLeafNodes in the outline. The onclick event on each of these nodes is supposed to run some code. The problem is both of those onClick events are being executed when the page is open but does not seem to execute when you actually click on the node.

知道哪里出了问题吗?

<xe:outline id="outline1">

<xe:this.treeNodes>
        <xe:basicLeafNode label="Set Value 1">
            <xe:this.onClick><![CDATA[#{javascript:getComponent("inputText1").value = "123";}]]></xe:this.onClick>
        </xe:basicLeafNode>
        <xe:basicLeafNode label="Set Value2">
            <xe:this.onClick><![CDATA[#{javascript:getComponent("inputText2").value = "456";}]]></xe:this.onClick>
        </xe:basicLeafNode>
    </xe:this.treeNodes>

</xe:outline>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>Value 1:&#160;
<xp:inputText id="inputText1"></xp:inputText>
<xp:br></xp:br>Value 2:&#160;
<xp:inputText id="inputText2"></xp:inputText>

推荐答案

basicLeafNode 的 onClick 事件仅适用于客户端 JS.您需要使用每个 basicLeafNode 的 submitValue 属性,然后将 SSJS 添加到大纲控件的 onItemClick 事件中.然后您可以使用 context.getSubmittedValue() 来检查点击了哪个节点,然后采取相应的行动:

The onClick event of the basicLeafNode is for client-side JS only. You need to use the submitValue property of each basicLeafNode to and then add SSJS to the onItemClick event of the outline control. You can then use context.getSubmittedValue() to check what node was clicked and then act accordingly:

<xe:outline id="outline1">
    <xe:this.treeNodes>
        <xe:basicLeafNode label="Set Value 1" submitValue="1"></xe:basicLeafNode>
        <xe:basicLeafNode label="Set Value2" submitValue="2"></xe:basicLeafNode>
    </xe:this.treeNodes>
    <xe:this.onItemClick><![CDATA[#{javascript:
        if (context.getSubmittedValue() == "1") {
            getComponent("inputText1").value = "123"
        } else if (context.getSubmittedValue() == "1") {
            getComponent("inputText2").value = "456"
        }
    }]]></xe:this.onItemClick>
</xe:outline>

来自 XPages 扩展库书籍(第 240 页):

From the XPages Extension Library book (page 240):

onClick 属性允许开发者执行一段客户端 JavaScript 代码和 submitValue 属性允许开发人员指定一个传递回服务器的值.这个值是从控件的 onItemClick 事件访问的包含树节点.

The onClick property allows the developer to execute a piece of Client-Side JavaScript code, and the submit- Value property allows the developer to specify a value that is passed back to the server. This value is accessed from the onItemClick event of the control that contains the tree nodes.

这篇关于Outline 中的 Onclick 事件在页面打开时执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆