<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font size="-1"><font face="Helvetica, Arial, sans-serif">Hello
John-Paul,<br>
<br>
I've done this in a recent project. 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. 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"> def
move_to_parent_location(parent, location)<br>
parent = nil if parent == 0<br>
parent = parent === self.class ? parent :
self.class.find(parent) if parent<br>
children = parent ? parent.children : self.class.roots<br>
<br>
if children.length > 0<br>
ord = location.to_i<br>
if ord > children.length<br>
self.move_to(children.last, :right)<br>
elsif children[ord] != self<br>
self.move_to(children[ord], :left)<br>
end<br>
elsif parent<br>
self.move_to(parent, :child)<br>
end<br>
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%;"> <img
src="cid:part1.09070503.03060706@gnexp.com" height="49" width="136"><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 <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>
</body>
</html>