I've been playing with Ryan Niemeyer's excellent knockout-sortable plugin and the draggable example in particular.
I'm looking to achieve two things:
- Create an observable array of draggable items.
- Rather than drag items into the sortable list, I want to drop dragged items onto items in the sortable list and replace their value.
In the below fiddle, I've begun the first objective but the Text: name
binding doesn't work. I'd appreciate any guidance with this and the second objective.
I'm not entirely sure what your issues with the code are, works pretty well already :). I do think I see what your problem is with the text: name binding, I think the change below fixes it the way you want it:
$data in this case represents the whole task, while name() represents the ACTUAL (string) VALUE of the observable name-attribute of the task. It seems this change makes it function the way you want it to.
The second objective is less clear to me. Which items should be droppable onto which items? E.g. should items from the right container be droppable on items of the left container? Or should everything be able to drop on/replace everything else? What about sort, is that even still needed?
jQuery droppable custom binding (in response to comments below)
To use it: