insertDomB > insertValueB > insertStyleB

41 views
Skip to first unread message

Bennit

unread,
Jul 22, 2012, 2:01:33 PM7/22/12
to fla...@googlegroups.com
I'm trying to insert dynamic behaviour in a css property of an existing element. Of course I could remake the element manually and insert the behaviour via an insertDomB over the existing element, but I was wondering if there was another way.

I've tried this:
insertValueB(liftB(function(v){return'height:'+v+'px;';},extractValueB('thickness')),'thickness-example','style')
which would make the style property of the element with ID border-example dynamic. However this does not work for some reason, it is as if the style property cannot be changed like this.

So I thought perhaps I need to change it using the w3 style name-attributes:
insertValueB(liftB(function(v){return{height:v+'px'}},extractValueB('thickness')), 'thickness-example','style');
=> Error: "deepDynamicUpdate: dynamic collections not supported"

Which I find a weird error since valueNow() of this extractedValue behaviour is no behaviour but simply a number.

Which brings me to my final question: is there no way to go deeper in the chain to insert behaviour values:
insertStyleB(prop) ~= insertValueB(behaviour,elem,style.prop)?

Any ideas / suggestions? I've tried looking at the code for insertValueB but I don't entirely get how the indexing works in dom elements so the code is hard for me to read.

Kind regards
Ben

Joe Gibbs Politz

unread,
Jul 22, 2012, 3:40:00 PM7/22/12
to fla...@googlegroups.com
Hi!  Thanks for your question.  Adding dynamic styles is actually straightforward, just badly documented.

insertValueB can take another string at the end to describe which part of the style you'd like to change.  Try this:

insertValueB(liftB(function(v){return v + 'px' }, extractValueB('thickness')),
             'thickness-example','style','height')

Let us know if you have any more troubles.  We'll put a similar example in the documentation to clear this up.
Reply all
Reply to author
Forward
0 new messages