Daniel F
Daniel F

Reputation: 134

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.

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!

Upvotes: 0

Views: 212

Answers (2)

Thomas Adrian
Thomas Adrian

Reputation: 3636

if you disable the theme for the button it should work

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

Upvotes: 3

Oliver Busse
Oliver Busse

Reputation: 3395

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

Upvotes: 0

Related Questions