These are chat archives for ractivejs/ractive

20th
May 2016
Guilherme Aiolfi
@guilhermeaiolfi
May 20 2016 13:58
Is there anyway to tell ractive how it should compare two objects?
for example: when binding a selected object in a <select /> element? I want to bind the whole object (and not just its ID because I'll show the selected data somewhere else).
but the object that I get from the server is different than the one that are in the select list
Guilherme Aiolfi
@guilhermeaiolfi
May 20 2016 14:09
To help see what I mean: http://jsfiddle.net/FarWn/92/
Such a common use case that angular has something called "track by" to use to compare the objects
I want to avoid observers for this
Martin Kolárik
@MartinKolarik
May 20 2016 14:39
there's no way to do that, as value will get converted to [object Object]
Martin Kolárik
@MartinKolarik
May 20 2016 14:45
but there definitely are different ways to achieve this: http://jsfiddle.net/FarWn/93/
(I changed the Ractive version from 0.3.7 to 0.7.3 - not sure if that was a mistake or you really use 0.3.7 but it won't work with such old version)
Guilherme Aiolfi
@guilhermeaiolfi
May 20 2016 16:15
I'm using 0.7.3, I get the first jsfiddle that I've found to illustrate what I was saying
Using a computed property is how I'm doing right know. But it's a little off still because the property I'm setting is deeply nested in my model
If that's something that other would like to see in ractive I could dive into and see if I can implement this feature
we would have to decide the API for it tho
Martin Kolárik
@MartinKolarik
May 20 2016 16:18
I looked into it but we're reading the values directly from <option> elements right now, so we are limited to strings
it isn't impossible but would require some changes
Guilherme Aiolfi
@guilhermeaiolfi
May 20 2016 16:20
Yeah, I look there too. I think it would be possible to keep BC in this case
Martin Kolárik
@MartinKolarik
May 20 2016 16:20
but I guess you can open an issue on GitHub to see what others think
Guilherme Aiolfi
@guilhermeaiolfi
May 20 2016 16:20
the behavior would change only if there was a track-by property in the select tag
all right
thanks
Martin Kolárik
@MartinKolarik
May 20 2016 16:21
np
Guilherme Aiolfi
@guilhermeaiolfi
May 20 2016 16:47
if someone wants to follow or contribute: ractivejs/ractive#2545