These are chat archives for canjs/canjs

1st
Mar 2017
lmagarian
@lmagarian
Mar 01 2017 17:58
I'm trying to use this code but it doesn't work: {(list)}="fields parentId"
fields is a function on the viewModel and parentId is a parameter I want to pass to that function
what's the right way to do this?
Kevin Phillips
@phillipskevin
Mar 01 2017 18:27
{(list)}=“fields(parentId)”
Kevin Phillips
@phillipskevin
Mar 01 2017 18:36
the way you had it should work also, except that parentId would be a compute and not the actual value
which is probably not what you want
lmagarian
@lmagarian
Mar 01 2017 18:58
thanks @phillipskevin
Kevin Phillips
@phillipskevin
Mar 01 2017 19:00
:thumbsup: no problem!
Viktor Busko
@Lighttree
Mar 01 2017 20:01

guys, I have a component's viewModel that contains object with an array of objects. So it's like

period: {
    prop1: ...,
    prop2: ...,
    myList: [
        {},
        {},
        ...
   ]
}

Define plugin automatically converts 'period' to can.Map, 'myList' to can.List, and its items to another can.Maps.
Is there a good way to 'Define' behavior of inner maps ? (elements of 'myList').
Basically I need to do some formatting and get/set in Define might be useful.

Chasen Le Hara
@chasenlehara
Mar 01 2017 21:32
Hi @Lighttree, it looks like you’re using CanJS 2, is that correct?
You can create a can.List type and then set its Map type so objects get converted into specific types: https://v2.canjs.com/docs/can.List.Map.html
That’s a little confusing so if it doesn’t make sense, you could create a JS Bin with your view model and we can provide some advice. 🙂
Here’s a JS Bin for CanJS 2: http://jsbin.com/venaje/embed?html,js,output