<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>After lots of reading I think the best way is to use simple draggables and droppables. After the drop i'll move the dragged node to the dropped one with move_to_child_of and after that i'll redraw the tree.</div><div><br></div><div>Any thoughts on that ?&nbsp;</div><div><br></div><div>Kind regards, John</div><br><div><html>On 19.03.2008, at 20:45, Jeremy Nicoll wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite"> <div bgcolor="#ffffff" text="#000000"> <font size="-1"><font face="Helvetica, Arial, sans-serif">Hello John-Paul,<br> <br> &nbsp;&nbsp;&nbsp; I've done this in a recent project.&nbsp; Basically the way I do it is check to see what order the a selected item in a list is in, and then move that item before/after a child node in the target parent based off this information.&nbsp; It's a bit complicated, but it's doable. I monkey patched the module SymetrieCom::Acts::NestedSet to include the following method to help me with this scenario:<br> <br> </font></font> <hr size="2" width="100%"><font size="-1"><font face="Helvetica, Arial, sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; def move_to_parent_location(parent, location)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parent = nil if parent == 0<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parent = parent === self.class ? parent : self.class.find(parent) if parent<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; children = parent ? parent.children : self.class.roots<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if children.length > 0<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ord = location.to_i<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ord > children.length<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.move_to(children.last, :right)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif children[ord] != self<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.move_to(children[ord], :left)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elsif parent<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.move_to(parent, :child)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br> </font></font> <hr size="2" width="100%"><font size="-1"><font face="Helvetica, Arial, sans-serif"><br> <br> </font></font> <div class="moz-signature"> <div style="line-height: 125%;"> <span>&lt;logo_sig.jpg></span><br> <span style="font-family: Arial,Helvetica,sans-serif; font-size: 9pt;"><b>Jeremy Nicoll</b><br> <a href="http://www.gnexp.com">www.gnexp.com</a><br> (801) 783-3831 </span> </div> </div> <br> <br> John-Paul Bader wrote: <blockquote cite="mid:9B3FAD14-7316-43A6-A318-1B45B250CFD8@medienhaus.udk-berlin.de" type="cite">  <pre wrap="">Hey there,

I just subscribed so i hope this question isn't redundant.

I'm trying to implement a sortable nested set.

I've already got an application with better_nested_set in place. I  
also got a nice nested &lt;ul> rendering for my tree. No I'd be able to  
drag an drop / sort elements across the set.

I found this Wiki entry which says that it wouldn't be a good idea in  
general to use sortable.create with :tree => true

<a class="moz-txt-link-freetext" href="http://whynotwiki.com/Rails_/_Sortable_trees">http://whynotwiki.com/Rails_/_Sortable_trees</a>

On the same page there is a link to the rubyonrails wiki stating that  
there is a fix expecially for better_nested_set. <a class="moz-txt-link-freetext" href="http://dev.rubyonrails.org/ticket/7807">http://dev.rubyonrails.org/ticket/7807</a>

My question would be what your experiences are. Is there a good way to  
implement a sortable / draggable better_nested_set ? If not do you  
have any suggestions, thoughs on this ?

Thanks and kind regards,

John (Berlin / Germany)
_______________________________________________
Betternestedset-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a>
<a class="moz-txt-link-freetext" href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a>

  </pre> </blockquote> </div>  _______________________________________________<br>Betternestedset-talk mailing list<br><a href="mailto:Betternestedset-talk@rubyforge.org">Betternestedset-talk@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/betternestedset-talk">http://rubyforge.org/mailman/listinfo/betternestedset-talk</a><br></blockquote></div><br></body></html>