如何使用 Awesome_nested_set 对节点内的节点重新排序

发布于 2024-08-28 21:44:08 字数 157 浏览 8 评论 0原文

如果我有一棵这样的树:

Page1
---Page1.1
---Page1.2
---Page1.3

使用 Awesome_nested_set,我将如何在 Page1 节点内向上或向下移动 Page1.x?

谢谢。

If I have a tree like this:

Page1
---Page1.1
---Page1.2
---Page1.3

Using awesome_nested_set, how would I move Page1.x up or down within the Page1 node?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

☆獨立☆ 2024-09-04 21:44:08

来自 http://github.com/collectiveidea/awesome_nested_set/blob/master/ lib/awesome_nested_set.rb

# Shorthand method for finding the left sibling and moving to the left of it.
def move_left
  move_to_left_of left_sibling
end

#Shorthand method for finding the right sibling and moving to the right of it.
def move_right
  move_to_right_of right_sibling
end

# Move the node to the left of another node (you can pass id only)
def move_to_left_of(node)
  move_to node, :left
end

# Move the node to the left of another node (you can pass id only)
def move_to_right_of(node)
  move_to node, :right
end

From http://github.com/collectiveidea/awesome_nested_set/blob/master/lib/awesome_nested_set.rb :

# Shorthand method for finding the left sibling and moving to the left of it.
def move_left
  move_to_left_of left_sibling
end

#Shorthand method for finding the right sibling and moving to the right of it.
def move_right
  move_to_right_of right_sibling
end

# Move the node to the left of another node (you can pass id only)
def move_to_left_of(node)
  move_to node, :left
end

# Move the node to the left of another node (you can pass id only)
def move_to_right_of(node)
  move_to node, :right
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文