jQuery:可排序的嵌套列表?

发布于 2024-08-17 13:03:20 字数 281 浏览 2 评论 0原文

我正在建立一个具有父子分页结构的网站。我正在寻找一种管理网站结构的便捷方法。

  • 我希望页面可排序

在我生成的站点地图(嵌套 UL)上释放 jQuery 可排序代码,但无法正常工作...

$('ul.SiteMap ul').sortable();

真正重要的是它不应该 > 可以在当前 UL 之外进行排序。有什么建议吗?

提前致谢。

i'm building a website which has a parent-child Paging structure. I'm looking for a convenient way to administrate the website structure.

  • I want the pages to be sortable

Releasing the jQuery sortable code on my generated sitemap (nested UL), doesn't work properly...

$('ul.SiteMap ul').sortable();

What's really important is that it should not be possible to sort outside of the current UL. Any suggestions?

Thanks in advance.

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

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

发布评论

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

评论(3

云淡月浅 2024-08-24 13:03:20

它对我来说效果很好。我只是将每个 ul 分配给一个类,然后执行以下操作:

$('.sortableList').sortable();

It works fine for me. I just assigned each ul to be sorted to a class and then did the following:

$('.sortableList').sortable();
凉城 2024-08-24 13:03:20

您是否尝试过:

items: 'ul > li'

不过,您必须列出所有 UL:

$('ul.SiteMap ul, ul.sitemap ul ul, ul.sitemap ul ul ul').sortable({
items: 'ul > li'
});

我是初学者,所以也许有更好的选择。

Have you tried with:

items: 'ul > li'

?

You have to list all ULs, though:

$('ul.SiteMap ul, ul.sitemap ul ul, ul.sitemap ul ul ul').sortable({
items: 'ul > li'
});

I am a beginner, so there is perhaps a better option.

む无字情书 2024-08-24 13:03:20

更改父级中子级的顺序很容易,只需给每个 ul 一个类 '.sort' 并执行 $('.sort').sortable();

当改变父母时我会变得有点棘手。

Changing order of children within a parent is easy just give each ul a class '.sort' and do $('.sort').sortable();

I gets a little trickier when changing the parent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文