[英]Change style class by changing scoped variable value
I have a button inside an xpages div and I am trying to compute the style class of that button based on a scoped variable. 我在xpages div中有一个按钮,我试图根据范围变量来计算该按钮的样式类。
Initially, the scoped variable's value is 'blue' and the background color of the button inside the div is blue as well. 最初,范围变量的值为'blue',并且div中按钮的背景颜色也为蓝色。
When I click on a second button, I set the value of the scoped variable to 'green' and do a partial refresh of the div. 当我单击第二个按钮时,我将范围变量的值设置为“ green”,并对div进行了部分刷新。
Now, I would expect the button to turn green, but the class is not being changed. 现在,我希望按钮会变为绿色,但不会更改类。
Here is the SSJS for computing the style class: 这是用于计算样式类的SSJS:
if(sessionScope.sTest == 'green'){
return 'btn-success';
}
else{
return 'btn-primary';
}
So, my question is, is a style class recalculated during a partial refresh or would I have to resort to either JQuery or Dojo in order to change the style class. 因此,我的问题是,是否在部分刷新期间重新计算了样式类,还是我不得不求助于JQuery或Dojo才能更改样式类。
Any help would be highly appreciated! 任何帮助将不胜感激!
如果您禁用按钮的主题,它应该可以工作
<xp:button id="btn" disableTheme="true"></xp:button>
请不要比较这样的Java字符串,而应使用.equals(“ ...”)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.