These are chat archives for canjs/canjs

11th
Jan 2018
AntonProkofyev
@AntonProkofyev
Jan 11 2018 10:00
Hi all, is there any way to call a method of child component VM from parent component?
Jeroen Cornelissen
@jeroencornelissen
Jan 11 2018 10:40
@AntonProkofyev If you use can-jquery you can do something like $(‘child-comp’).viewModel().myFunction();
Or you could use can-view-model https://canjs.com/doc/can-view-model.html
AntonProkofyev
@AntonProkofyev
Jan 11 2018 10:49
@jeroencornelissen thx
Kevin Phillips
@phillipskevin
Jan 11 2018 20:44
you can pass the function to the child through bindings
Frank Lemanschik
@frank-dspeed
Jan 11 2018 20:45
Oh Kevin do you know the syntax for stache
That renders a dynamic varname
Or property?
I want to use it to select language translation based on a lot lang var
Kevin Phillips
@phillipskevin
Jan 11 2018 20:47
I'm not exactly sure what you mean
{{ [foo] }}
Frank Lemanschik
@frank-dspeed
Jan 11 2018 20:48
I mean something like en.intro_text
While en should point to this.lang
Kevin Phillips
@phillipskevin
Jan 11 2018 20:49
{{ [lang].intro_text }}
but you might not want to do it that way
it might be faster to just have a currentLang property that is derived from the selected language
so it doesn't have to do two lookups for each key
Frank Lemanschik
@frank-dspeed
Jan 11 2018 20:54
Hmm also a great idea
Thanks a lot
Kevin Phillips
@phillipskevin
Jan 11 2018 21:00
actually most projects I've done translation on, we've just created a helper
because then if you don't have one of the keys translated, you can just use the key as a fallback
{{i18n("this is the intro text")}}