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
each helper not updating changes #11880
Comments
Which Embwr version? Can you put together a JSBin or ember-twiddle demonstrating this? |
I think it might have something to do with sortable modifying the elements, by adding classes and styles. |
@rwjblue the ember-twiddle shows Ember v1.13.5 |
I have same issue with ember + jqueryui sortable EmberSherpa/ama#10 |
Any thoughts? |
I'm seeing this too on Ember 1.13.5. Here are the relevant bits of my component: // components/page-list.js
didInsertElement: function() {
var pageListComponent = this;
this.$("ul.procedure").sortable({
items: 'li:not(:first-child)',
update: function(event, ui) {
var sortOrder = Ember.$(this).sortable('toArray', { attribute: 'data-id' });
var pageModels = [];
sortOrder.forEach(function(id, index) {
pageModels.push({
id: id,
display_index: index
});
});
Ember.$(this).sortable('cancel');
pageListComponent.sendAction('updateSortOrder', pageModels);
}
});
} <!-- templates/components/page-list.js -->
<ul class="procedure">
{{#each pages as |page|}}
<li class="page-template" data-id="{{page.id}}">
<a class="open-page" {{action 'editPage' page}} data-id="{{page.id}}">
<span class="page-label">Page {{page.id}}, Display {{page.displayIndex}}</span>
</a>
</li>
{{/each}}
</ul> |
@dmagunov we are aware of this issue, but haven't gotten to it yet. @krisselden has implemented (and may still maintain) some ember drag & drop code. Maybe he has some free time this week. |
@stefanpenner any news? |
I'm not sure if this is the same issue. I have a helper inside of an each loop and the helper doesn't seem to fire when I update one of its properties. Thoughts? |
I am also experiencing the issue. Is there maybe some way to manually trigger the each helper to refresh? |
It's sloppy, but I got it to work for now by wrapping the {{#if showList}}
{{sortable-list ...}}
{{else}}
{{sortable-list ...}}
{{/if}} actions: {
listUpdated() {
this.set('showList', false);
Ember.run.next(this, function() {
this.set('showList', true);
});
}
} Here's the updated twiddle: |
@stevehanson thanks for example, but in Your case ember rerenders whole list, so focus, selection and so on is lost. |
@dmagunov: Yeah, definitely not ideal. What is your scenario where you have focus or selection you would like to preserve? Since the list is only re-rendered after dropping a sortable element into a new position, it doesn't seem like you would have any focus or selection to worry about. |
@dmagunov oh, i see. Thought you were having the same problem with jQuery UI sortable. Your case seems a little trickier :( |
I see that the developers have forgotten about us) |
+1 just ran into the issue that @jrjohnson had with that twiddle and we had very similar code. A few things I noticed:
|
@jrjohnson After some poking around, I fixed the problem in the twiddle by specifying |
I'm trying to disentangle this issue and it seems that there a couple different things going on in here. @jrjohnson / @aldhsu - There are two issues in the twiddle from #11880 (comment):
Fixed example: http://ember-twiddle.com/35ec52938a0cb6205da3 The main issue here is related to using jQuery sortable as experienced by @QuantumKing / @dmagunov / @stevehanson. I do see the issue, but I'm not 100% sure what is actually going on here yet. Does this work in 1.12 (a quick switch of the twiddle to 1.12.1 seems to show even more issues)? |
@rwjblue it doesn't work properly either on 1.12 and latest 1.13 versions. But issues is differs. The main problem with glimmer engine is to tell him that "content (DOM) of each is changed, so refresh it" after sort finished and model updated. |
@rwjblue thanks for the quick reply. Apologies, I didn't understand helpers are analogs for computed properties in DOM and would not be recomputed unless what they observe has changed. I forced recomputes on helpers that observed arrays by passing in |
@aldhsu - Yep, definitely works that way too! |
@rwjblue I didn't know either of those things and now I do! Thanks! |
Experiencing this same issue with https://github.com/RubaXa/Sortable. |
We are also experiencing the issue with jquery sortable on Ember 1.13.9. I have a controller action to sort our {{#sortable-list updateSortOrder='sortItems'}}
{{#each model.items as |item index|}}
{{#sortable-item item=item index=index}}
{{item.filename}}
{{gallery-item item=item activeIds=activeIds galleryId=model.id remove="remove" toggleActive="toggleActive"}}
{{/sortable-item}}
{{/each}}
{{/sortable-list}} It seems the sortable plugin does something that interferes with the |
I think I have a similar issue. Here's a JSbin that shows the issue: Observers/computed properties in a component that gets its value from an each aren't triggering on changes to that value. Workaround I've been using is having a different, non-object property trigger the observers/computed properties instead. Ember v1.13.8 |
ping @wycats , only You can help us with this issue |
As a work around, I was able to get our sortable table working by calling
|
@JaroVDH http://emberjs.jsbin.com/qitusawavi/1/edit?html,js,console,output there is nothing causing it to call the helper again because it sees the same obj. |
This issue is just a dumping ground for complaints about each with not much that is actionable. Only provided examples jsbin/ember-twiddle are actually working as designed, misunderstanding about helpers and interior object mutations. The rest are misc issues with addon breakage. Please open an issue on those addons. |
This still seems to be an issue in Ember 2.13. Passing a |
I have a component
sortable-list
which has the following templateand code
In one of my templates I have
The problem I'm having is when I sort the items and
updateItemOrder
gets called, withremoveObject
andinsertAt
updating theitems
array, the list is not being re-rendered. This used to work before I moved this code from my route's view to a component.The text was updated successfully, but these errors were encountered: