jQuery: Sortable nested list?

匿名 (未验证) 提交于 2019-12-03 09:18:39

问题:

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.

回答1:

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

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


回答2:

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.



回答3:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!