Skip to content
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

Ember array not properly updating in template #11701

Closed
JarrodCTaylor opened this issue Jul 9, 2015 · 10 comments · Fixed by #13359
Closed

Ember array not properly updating in template #11701

JarrodCTaylor opened this issue Jul 9, 2015 · 10 comments · Fixed by #13359
Assignees

Comments

@JarrodCTaylor
Copy link

In the JSBin click the button and it will add an item to the array. The loop in the template will display the new item but were we have only {{exmapleArray}} will not show the change. If you visit the distraction route when you return you will see the exampleArray has been updated.

http://emberjs.jsbin.com/dewuna/edit?html,js,output

@mattjmorrison
Copy link

Interesting... is this a Glimmer bug? @JarrodCTaylor this happens in 1.13 and not in 1.12, correct?

@jakesjews
Copy link
Contributor

I think this is related to #11549. If you change the each to {{#each exampleArray key='@index' as |thing|}} then it works as expected.

@mattjmorrison
Copy link

@jakesjews I don't think that is the same problem. In this example the #each is working as expected, it's the {{exampleArray}} that is not working.

@jakesjews
Copy link
Contributor

Now i see it. I was thinking it was the fact that 1.13 only lets you add one item while 1.12 added as many as you clicked. It looks like it doesn't work in 1.12 either unfortunately.

@JarrodCTaylor
Copy link
Author

I have created another bin to exactly duplicate the production issue that I am experiencing with 1.13.X

http://emberjs.jsbin.com/qujeba/edit?html,js,output

In 1.12.X the if check on the array will update the class resulting in a color change to the <h4> However, in 1.13.X you need to visit a different route and return in order to see the change reflected.

@mixonic
Copy link
Member

mixonic commented Jul 9, 2015

@JarrodCTaylor I believe you want to bind to exampleArray.length. IMO the 1.13 behavior is correct- the array is always present, thus the if should evaluate true.

@stefanpenner stefanpenner self-assigned this Jul 9, 2015
@JarrodCTaylor
Copy link
Author

@mixonic the behavior is inconsistent. I updated the bin to have a

{{#if exampleArray}}
  <p>This is true now</p>
{{/if}}

Which is updated. However, the <h4 class={{if exampleArray 'blue' 'red'}}>Example text</h4> is not.

@mixonic
Copy link
Member

mixonic commented Jul 9, 2015

I definitely agree they should behave consistently!

@krisselden
Copy link
Contributor

I updated the jsbin here to clarify some of the examples: http://emberjs.jsbin.com/pobepubiba/4/edit?html,css,js,output

@mixonic the magic if conditional on length was I think to be consistent with #each else or Ember.isEmpty?

@rwjblue
Copy link
Member

rwjblue commented Apr 18, 2016

Will be fixed by #13359.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants