通过更改作用域变量值更改样式类 [英] Change style class by changing scoped variable value

查看:212
本文介绍了通过更改作用域变量值更改样式类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在xpages div中有一个按钮,我试图根据一个作用域变量计算该按钮的样式类。



最初,作用域变量的值是蓝色,div内的按钮的背景颜色也是蓝色。



当我点击第二个按钮时,我设置了scoped变量的值to'green'and do a partial refresh of the div。



现在,我希望按钮变成绿色,但是类没有改变。



这是用于计算样式类的SSJS:

  if(sessionScope。 sTest =='green'){
return'btn-success';
}
else {
return'btn-primary';
}

所以,我的问题是,是一个样式类在部分刷新期间重新计算,我将不得不求助于JQuery或Dojo以更改样式类。



任何帮助将非常感激!

 如果你禁用了按钮的主题, < xp:button id =btndisableTheme =true>< / xp:button> 


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.

Initially, the scoped variable's value is 'blue' and the background color of the button inside the div is blue as well.

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.

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:

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.

Any help would be highly appreciated!

解决方案

if you disable the theme for the button it should work

<xp:button id="btn" disableTheme="true"></xp:button>    

这篇关于通过更改作用域变量值更改样式类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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