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

Glimmer and Jqueryui sortable #10

Open
dmagunov opened this issue Jul 23, 2015 · 6 comments
Open

Glimmer and Jqueryui sortable #10

dmagunov opened this issue Jul 23, 2015 · 6 comments

Comments

@dmagunov
Copy link

Hello!

I have some issues with working together new Ember engine and jqueryui sortable plugin.
My structure (example):

Model Project:

itemSorting: ['sort']
itemSorted: Ember.computed.sort('item_ids','itemSorting'))

Model Item:

project_id: DS.attr('belongsTo', 'project', {async:true})

Template:

{{#jqui-sortable}}
{{#each project.itemSorted as |item index|}}
  {{item-element  index=index }}
 {{/each}} 
{{/jqui-sortable}}

So after sorting - jqui-sortable component sends action to route with new indexes of each item and route saves models and pushes new sort properties to store. So problem is that sometimes glimmer engine doesn't properly rendered sorted list. Indexes inside "each" are correct but display order of items isn't. I think that it caused by dom manipulation of item list (changing order of item (LI) list) by sortable plugin. My question is how to tell glimmer engine to forcev rerender this list (component.rerender() doesn't help)?

@taras
Copy link
Member

taras commented Jul 23, 2015

What's the problem? :)

@dmagunov
Copy link
Author

Hello, I've updated my question)

@taras
Copy link
Member

taras commented Jul 23, 2015

@dmagunov if you're using Ember 1.13.2+, you can specify key="@index" on your {{each}} helper. Like this

{{#jqui-sortable}}
{{#each project.itemSorted key="@index" as |item index|}}
  {{item-element  index=index }}
 {{/each}} 
{{/jqui-sortable}}

This will use item's index in the array to order the elements in each.

@dmagunov
Copy link
Author

Thanks Taras, yes I'm using 1.13.5 and already try this but it doesn't helped me. I've made video to illustrate this issue https://youtu.be/UFIjX_YHoP0

@dmagunov
Copy link
Author

And if I've directly update sort property - all works as expected. https://youtu.be/CbcHUHU7ykw

@taras
Copy link
Member

taras commented Aug 3, 2015

@dmagunov thanks for linking to that issue

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

No branches or pull requests

2 participants