Change style class by changing scoped variable value

こ雲淡風輕ζ 提交于 2019-12-25 01:22:49

问题


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!


回答1:


if you disable the theme for the button it should work

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



回答2:


Please don't compare Java Strings like that, use .equals("...") instead.



来源:https://stackoverflow.com/questions/27694776/change-style-class-by-changing-scoped-variable-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!