Fork me on GitHub
#hoplon
<
2017-11-04
>
gscacco17:11:28

hi, I have a problem with the :class attribute changed dynamically by cell=

gscacco17:11:34

it seems that changing the cell value the class attribute is not overwritten (as expected) but the new value is appended to it !

gscacco17:11:16

<li class="active" ... />

gscacco17:11:55

<li class="active inactive" ... />

gscacco17:11:59

instead of

gscacco17:11:14

<li class="inactive" ... />

gscacco17:11:57

All the other attributes work as expected !

dm318:11:18

can you show the code?

gscacco18:11:22

(li {:class (active :home)} (a :href "#" "Home" :click #(reset! cp :home)))

gscacco18:11:50

(defn active [p]
  (cell= (if (= cp p) "active" "inactive")))

gscacco18:11:24

in this case I use a function (active)

gscacco18:11:59

but the behaviour is the same using directly cell=

gscacco18:11:28

If you change :class in :classs it works correctly !

flyboarder18:11:42

@gianluca.scacco thats not quite what you want

flyboarder18:11:52

you are looking to provide the attribute with a map

flyboarder18:11:28

like this: (div :class (cell= {:active true :inactive false}))

flyboarder18:11:46

where true/false probably comes from another cell

gscacco18:11:11

ok, now works. Thank you ! But why this happens only with the class ?

flyboarder21:11:45

@gianluca.scacco it’s not just the class attribute, however :class is one that has a few different cases for the types of data it accepts