TonyS
Posts: 0
Joined: Thu Jun 11, 2015 12:11 pm

Change button colour based on value from database

I can set the button text from my db and wondered if it would be possible to set the button colour in the same way?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Change button colour based on value from database

Hello Tony,

For the AngularJS apps:
1) get the values from DB
2) apply certain class (previously defined in css) using ng-class
https://scotch.io/tutorials/the-many-...

ng-class -- color-for-{{valueFromDB}}

in CSS

.color-for-value1 { ..styling }
.color-fro-value2 { ..styling }

etc.

For the JQM apps:
1) please add JS to the button's mapping:

$(element).addClass("color-for-" + value);

TonyS
Posts: 0
Joined: Thu Jun 11, 2015 12:11 pm

Change button colour based on value from database

Thanks Sergiy,

I'll try it with jquery and let you know,

Return to “Issues”