I'm building a drag-and-drop outline tool. It uses jQueryUI's .sortable() in a nested fasion to build a tree of elements. I also have a palette of items using .draggable() that can be dragged into the outline at any given level.
Dropping a new item into the topmost level of the tree works fine. But when I drop one into the 2nd level down, the item gets duplicated. When I drop one into the 3rd level, the item gets duplicated twice! I've boiled the problem down to its essence here: http://jsfiddle.net/curtisfarnham/TGAqW/
How can I prevent items from getting duplicated when dropped into the lower levels of the tree?