Question

excuse the hacked together sample

http://jsfiddle.net/marcmeans/SqrBf/1/

If you add an item from the available students to Table3 twice and then try and move one from Table3 to Table2, both disappear.

I note as well that when I'm generating a new guid for the item added to Table3, the arg.item seems be a reference to the item in the source list and not a clone. This creates a link in knockout where if I update one I update them all.

I'm assuming that I am doing something wrong here, but I'm having a hard time figuring out what.

Was it helpful?

Solution

The draggable functionality in the sortable plugin currently checks to see if your object has a clone function on it. If it does, then it uses the result of calling clone as the new item. If not, then it uses the item itself.

In your fiddle, you are using the mapping plugin, so one option would be to pass mapping options that customize how your students are getting created by adding a clone method.

Here is an updated fiddle that passes the mapping options and clones the object just by doing ko.mapping.fromJS(ko.mapping.toJS(this))

http://jsfiddle.net/rniemeyer/SqrBf/3/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top