-
Notifications
You must be signed in to change notification settings - Fork 421
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
Iterating over component data not as expected #583
Comments
How does it get the map? Can you add a test or a better explanation of the setup code. Sent from my iPhone
|
I thought the Fiddle illustrates the issue. As far as I can tell it doesn't really matter how the component gets the map (pre-initialized, as a plain object on the prototype or set as |
Odd, my email did not include the fiddle link, but the website does. Sent from my iPhone
|
Oh, I've spent more than 2 hours banging my head around this one, with no success. Any tips on where I should look? Thanks. |
The problem is your can.Map in scope, for whatever reason, gets "upgraded" to a can.compute, by default with can.computes in #each we treat it as a list. #each goes something like this: 1.) If you are a compute, or you've an observable list, live bind iterate with can.view.lists So in can.view.Scope it gets stuck at the first one, because the can.Map is wrapped in a can.compute. Is there a reason we're doing this? Perhaps some obvious solution that I'm missing. |
This commit adds a test that uses can.Component to render an {{#each}} block. The bug is unique to can.Component because can.Component wraps the can.Maps as computes. for canjs#583
This commit fixes issue canjs#583 by allowing the live bindings within can.view.lists to work with can.Maps as well as more list-y things. This is needed because using #each with a can.compute always goes through can.view.lists.
Decided the fix was whack, going to try a different approach. Should be easy to fix it right within |
@matthewp ping me tomorrow to go over it. |
What's the verdict on this one? |
A component with a simple template like
Will not iterate as expected over the values in the
data
map. With a map likeThe template in a component will output:
Where the same template rendered via Mustache directly is the correct
Demo Fiddle: http://jsfiddle.net/GzpnF/1/
The text was updated successfully, but these errors were encountered: