RamonSmit / Nestable2

New pickup of Nestable!
Other
322 stars 147 forks source link

How to refresh (rebuild) tree in Nestable plugin? #99

Closed nurzhannogerbek closed 6 years ago

nurzhannogerbek commented 6 years ago

First of all THANK YOU for this wonderful library! :)

I use Nestable2 to create tree in my project. I need to refresh (rebuild) tree when it was updated by ajax. I used next code. It create tree correctly but I can't change (move) depth (level). How to fix this problem?

$('.dd').nestable('init').nestable({maxDepth: 6}).nestable('collapseAll');

nurzhannogerbek commented 6 years ago

It seems to me that init function don't have move horizontal opportunity which was set here. Do you have any ideas how to fix this problem?

nurzhannogerbek commented 6 years ago

Well, finally I found the solution. Next code works for me:

$('.dd').nestable('destroy');
$('.dd').nestable({maxDepth: 6}).nestable('collapseAll');