There are a few examples online of using jQuery sortable with Ember.js. They all have different problems:
- They don’t have two way binding. If you drag the items around they will update the underlying data model, but if you update the data model, they don’t reflect the changes in the list.
- They aren’t reusable. If you want multiple lists throughout your application, you need to copy and paste all the logic. I’d like to be able to drop the list in multiple places, only rewriting the template code for how to display each item.
- They aren’t extensible. I want to be able to call into the native jQuery hooks for the sortable when I need to.
- Many are out of date and no longer work.
Angular UI has a really nice sortable widget. I tried my hand at recreating it, but I’m stuck in a few places. Problems I’m having:
- In the sortable callbacks, I have access to the ul and li, and I can iterate over the li items, but can I know which li is associated with which object in my Ember context array. (I could probably go by position, but this isn’t reliable if I have multiple lists.
- My observer function is never called when the list changes. Perhaps the string I pass is incorrect.
Any help is appreciated!