jquery nested sortable list

十年热恋 提交于 2019-12-05 02:41:57

问题


i have this code

$(document).ready(function() {
    $("#test-list").sortable({
        items: "> li",
        handle : '.handle',
        axis: 'y',
        opacity: 0.6,
        update : function () {
            var order = $('#test-list').sortable('serialize');
            $("#info").load("process-sortable.asp?"+order+"&id=catid&order=orderid&table=tblCats");
        }
    });
    $("#test-sub").sortable({
        containment: "ul",
        items: "li",
        handle : '.handle',
        axis: 'y',
        opacity: 0.6,
        update : function () {
            var order = $('#test-list').sortable('serialize');
            $("#info").load("process-sortable.asp?"+order+"&id=catid&order=orderid&table=tblCats");
        }
    });
});

for this kind of UL

<ul id="test-list">
  <li></li>
  <li>
    <ul id="test-sub">
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
      <li></li>
   </ul>
  </li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul>

but it can be changed dynamiclly... when i drag and drop the main li it is working when i do it with the childs it will drag the main one

what is wrong?


回答1:


I blogged on this. It's not that straight forward and a bit confusing, but simple really.

http://a.shinynew.me/post/4641524290/jquery-ui-nested-sortables




回答2:


I wrote a drag and drop script specially designed for nested structures Check it out... https://supraniti.github.io/Lean-Mean-Drag-and-Drop/



来源:https://stackoverflow.com/questions/2487026/jquery-nested-sortable-list

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