xpages-如何从客户端javascript设置作用域变量? [英] xpages - how to set a scope variable from client side javascript?

查看:59
本文介绍了xpages-如何从客户端javascript设置作用域变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从客户端JavaScript设置XPages范围变量.我有一个XPage,其中包含使用Dojo显示或隐藏的几个部分.在此XPage上,我有一个执行服务器端JavaScript的按钮.一旦按钮后面的SSJS执行,默认情况下XPage的可见部分将再次可见,而不是单击按钮之前立即可见的部分.我希望在单击按钮之前的可见部分也可以在执行按钮后面的SSJS之后看到.

I'm trying to set an XPages scope variable from Client side JavaScript. I have an XPage which contains several sections which are shown or hidden using Dojo. On this XPage I have a button which executes some server side JavaScript. Once the SSJS behind the button executes, the section of the XPage which is visible by default is again visible, rather than the section which was visible immediately prior to the button being clicked. I would like the section which was visible prior to the button being clicked to also be visible after the SSJS behind the button has executed.

为此,我考虑过使用范围变量-使用客户端JavaScript计算XPage的当前可见部分,在范围变量中设置此值,并在 onClientLoad <中读取范围变量XPage的/code>事件再次使该部分可见(并隐藏所有其他部分).但是,我找不到从客户端JavaScript设置作用域变量的方法.我尝试添加

To do this I have thought of using a scope variable - use client side JavaScript to calculate which section of the XPage which is currently visible, set this value in a scope variable and read the scope variable in the onClientLoad event of the XPage to again make this section visible (and hide all other sections). However, I have found no way of setting a scope variable from client side JavaScript. I have tried adding

var xyz = "#{javascript:viewScope.put('sectionDisplay','Section')}"

到按钮的 onClick 客户端事件,但这将设置范围变量,无论是否单击按钮.

to the onClick client event of the button but this sets the scope variable regardless of whether the button is clicked or not.

在XPages之前,我将使用querystring将变量从一页传递到另一页.我现在该怎么做?

Before XPages, I would have used the querystring to pass variable from one page to another. How can I now do this?

推荐答案

另一种方法:也许您根本不需要scope变量,如果您只想隐藏某些东西,可以将其style属性设置为"display:没有任何".

One other approach: perhaps you don't need the scope variable at all, if you just want to hide something, you can set it's style property to "display:none".

例如,您有以下div:< xp:div id ="mydiv"> ...</xp:div>

For example, you have this div: <xp:div id="mydiv">...</xp:div>

然后,您可以在按钮中使用以下CSJS:

Then you can use the following CSJS in a button:

dojo.byId(#{id:mydiv}").style.display ="none"

这篇关于xpages-如何从客户端javascript设置作用域变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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