Page 1 of 1

Change button colour based on value from database

Posted: Thu Dec 17, 2015 2:24 pm
by TonyS

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?


Change button colour based on value from database

Posted: Thu Dec 17, 2015 5:42 pm
by Serhii Kulibaba

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);


Change button colour based on value from database

Posted: Fri Dec 18, 2015 10:27 am
by TonyS

Thanks Sergiy,

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