These are chat archives for canjs/canjs

1st
Jun 2015
dylanrtt
@dylanrtt
Jun 01 2015 14:10
@patrickclancy Personally, I would do this with something at the view layer such as custom attributes so you don't have to litter your map definitions with knowledge of how they might be used in the view http://jsbin.com/zozuhevosa/2/edit?html,js,output
Patrick Clancy
@patrickclancy
Jun 01 2015 15:55
@dylanrtt That’s cool! I like your idea of pulling it out of the model. ;-)
Alexis Abril
@alexisabril
Jun 01 2015 19:40
@patrickclancy Ah, slightly updated version: http://jsbin.com/yexiji/3/edit
Adam L Barrett
@BigAB
Jun 01 2015 19:48
@alexisabril that example logs true for both valid and invalid selections
Patrick Clancy
@patrickclancy
Jun 01 2015 19:48
@alexisabril nice!! What do you think about @dylanrtt idea of making a custom attribute or componet?
Alexis Abril
@alexisabril
Jun 01 2015 19:50
taking a quick peak just now
I like the abstraction
it’s basically a custom can-value
any reason checkboxes aren’t used for the boolean type instead of a radio button?
I know angular actually has filters for this type of stuff(turning a bool -> string, etc aside from the data layer and view)
Patrick Clancy
@patrickclancy
Jun 01 2015 19:53
yea.. it’s nice when the map prop is on a model. The existing app uses this radio section convention.
Alexis Abril
@alexisabril
Jun 01 2015 19:53
gotcha
yeah, in this case it’d be cool either way
if it gets really complex(re-structuring an object), I typically have a viewmodel inbetween the actual model and whatever is using it
and then put all my conversions in there
I’m starting to get drawn back to the filters approach though

then you could do:

<input type=“radio” can-value=“{foo}” can-type=“boolean”/>
<input can-value=“{modifiedAt}” can-type=“date”/>
<input can-value=“{price}” can-format=“$dd.dd”/>

or something

those syntaxes were off the top of my head, don’t hold me to those ;)
Patrick Clancy
@patrickclancy
Jun 01 2015 20:01
ahh interesting…. "a viewmodel inbetween the actual model” I’ll need to think about how to implement that. I like the can-type=“…” you’ve really got me thinking about the possible ways to skin the model cat.
Alexis Abril
@alexisabril
Jun 01 2015 20:04
heh, I feel like I did a can-currency-value a while back for this type of stuff
I just want a normalized way to do conversions between the presentation/data layer elegantly
Gerard Finnerty
@halcyonandon
Jun 01 2015 23:50
@alexisabril arent mustache helpers appropriate to use when you want the view format to be different than the data format? That's what I use for currency, date, et al. ...unless I'm misunderstanding the original question