These are chat archives for canjs/canjs

28th
Nov 2017
Eben
@eben-roux
Nov 28 2017 10:37
I have just gotten used to the propName:from business and attribute=''... :)
why not rather use something that is more explicit?
perhaps propName:value='theValue'?
perhaps I'm missing something...
Kevin Phillips
@phillipskevin
Nov 28 2017 15:43
I'm not sure what you're suggesting @eben-roux
can you explain?
you mean add a new binding keyword specifically for string values?
Chasen Le Hara
@chasenlehara
Nov 28 2017 17:45
We’re going to start our contributors meeting in just a moment: https://www.youtube.com/watch?v=66j46ji0D_o
Eben
@eben-roux
Nov 28 2017 17:45
@phillipskevin Hi Kevin... yes :)
it wouldn't be just for 'string' values though but for any value
wouldn't it be more explicit?
having propName:from="'value'" seems like trying to escape the value and bypass the binding
just seeing the attribute="value" thread that appears to have changed --- but perhaps I've missed the boat somewhere
Kevin Phillips
@phillipskevin
Nov 28 2017 20:56
@eben-roux any value not from the scope you mean?
propName:from="'value'" is not trying to bypass the binding... it's just bypassing a scope lookup
propName:from="value" will look up value in the scope and set propName on the viewModel
propName:from="'value'" will look up 'value' and find a string and set propName on the viewModel to be that string
Nico R.
@nriesco
Nov 28 2017 21:41
more of the same topic… how can I apply a css class depending on the result of a function? I could do it like this: {{#if some()}}<div class=“class1”>hello</div>{{/if}} but I was hoping to do something easier like <div class:from=“getClasses()”>hello</div> is that possible with those bindings?
Brad Momberger
@bmomberger-bitovi
Nov 28 2017 21:46
yes, that should work fine.
I seem to remember doing that before.
Unless that didn't work and I'm misremembering.
I just checked in a JSBin and it works fine.
so feel free to use that. Keep in mind that if you do that on an element with a viewModel attached, you'll probably want to specify an element property (i.e. el:class:from="getClasses")
Nico R.
@nriesco
Nov 28 2017 22:31
Ok, so el:class:from=“getClasses()” would return the value to the vm whereas class:from=“getClasess()” to the class property of the html element?
And another question, getClasess should or should not have the () ? is it executing it or binding it?
Brad Momberger
@bmomberger-bitovi
Nov 28 2017 22:32
el:class:from="getClasses()" explicitly sets on the element.
vm:class:from="getClasses()" explicitly sets on the view model
class:from="getClasses()" sets on the view model if there is one, otherwise sets on the element.
With stache 4.0, () will be required to execute functions, so leave that on for future-proofing.
Nico R.
@nriesco
Nov 28 2017 22:33
great, thanks @bmomberger-bitovi