Change style class by changing scoped variable val

2019-09-01 06:03发布

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!

2条回答
Ridiculous、
2楼-- · 2019-09-01 06:20

if you disable the theme for the button it should work

<xp:button id="btn" disableTheme="true"></xp:button>    
查看更多
Emotional °昔
3楼-- · 2019-09-01 06:36

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

查看更多
登录 后发表回答