New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrapping can.compute in can.Map breaks live-binding #530
Comments
Man...this was a tricky one to track down. It turns out that when you wrap a compute in a can.Map, upon setting a value for that compute, it unintentionally changes that attribute's value to the result of the compute. |
So after talking with @justinbmeyer we came to the conclusion that this is intended...ish. What you want to do, using your fiddle as an example, is: this.options.testMap.attr('test')('after2'); This will get the compute on testMap, then you can call it with the value you want to change it to. This is where my previously stated "ish" comes into play. Currently if you do This should still be in 2.0.2 which should be landing later today. |
Hey Josh, thanks for looking into this! I'm not quite sure if that's the same thing you are into here, but that may totally be on me - is it? Best regards, |
Hey Fabian, I'm pretty sure we're on the same page. After this code I committed get's merged, your example will work in 2.0.2 just by changing this.options.testMap.attr('test', 'after2'); to this.options.testMap.attr('test')('after2'); The issue with c2('after') not updating accordingly was fixed in 2.0.1 (Give http://jsfiddle.net/FLj7b/1/ a looksie, which uses 2.0.1). |
Fixes #530 doing .attr get on a compute returns compute and not compute's value
When a can.compute is wrapped in a can.Map and then live-bound, the view will not update when the compute changes.
I have an app that has a global can.Map for storing the state, so when I now put in a can.compute anywhere in this Map (manually or by accessing can.route.data for example, which is part of this state), the compute will never update the view.
See here for a very basic example: http://jsfiddle.net/simpleFabian/FLj7b
Is this behaviour intended in some way?
Can I work around it temporarily in any way? (as in using a helper, maybe?)
Thanks in advance!
The text was updated successfully, but these errors were encountered: