简体   繁体   中英

Coffeescript Dashing widget backgroundcolor

Good Morning everyone,

I'm currently trying to change the backgroundcolor for my widgets. Somehow it just doesn't work.

This is what my job file delivers:

return_array.push({value: value, label: row[0], color: color})

network = status_array[0..1] # This is pretty much return_array

send_event('network', {items: network[0]}) # sending data to the widget with data-id network

The widget I am using is the list widget.

Here's what my Coffeescript file looks like:

class Dashing.List extends Dashing.Widget

onData: (data) ->
  color = data.items.color
  $(@node).addClass "#{color}"

 ...

Color delivers either 'red' or 'green'

In my css file I got it setup like this:

.green {
  background-color: $background-color;
}

.red {
 background-color: #f13a2a;
}

Does anyone have an idea why it won't add the class? I can alert color and get back the value red / green

try

onData: (data) =>
  color = data.items.color
  $(@node).addClass "#{color}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM