ilikenwf / nestedSortable

A jQuery plugin that extends Sortable UI functionalities to nested lists.
645 stars 221 forks source link

toArray adds one extra item #37

Open ltdev22 opened 9 years ago

ltdev22 commented 9 years ago

Hi I'd like to ask a question please.

I'm using the nestedSortable plugin in order to move nodes in my tree. My tree looks like this http://ftp.nchu.edu.tw/MySQL/tech-resources/articles/hierarchical-data-4.png , so my root node (Electronics) has always left == 1 and right == 20 (or any max value). When I hit my 'save' button the toArray returns one extra item (supposed as root) and breaks my tree structure, i.e. it gets the left and right values of my root (Electronics) and my root becomes a child node.

How can I fix this, so that the extra item of the toArray will get always the same left and right values as my root and don't brake the tree?

twicejr commented 9 years ago

I think this is not a big problem, and will likely break existing websites that use it as is, currently. Maybe I'm a bit too pessimistic here, but i.m.o., a version 2 must fix these problems. Can you not fix it in your backend?

Maybe I will do an attempt on a version 2.0 in the future. I'm not the project owner though ;)

@see https://github.com/jquery/jquery-ui/blob/master/ui/sortable.js as well.