Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqueryui可排序。是否阻止将一个特定项目放入另一个特定项目?_Jquery_Jquery Ui_Jquery Ui Sortable - Fatal编程技术网

jqueryui可排序。是否阻止将一个特定项目放入另一个特定项目?

jqueryui可排序。是否阻止将一个特定项目放入另一个特定项目?,jquery,jquery-ui,jquery-ui-sortable,Jquery,Jquery Ui,Jquery Ui Sortable,我有一份菜单,看起来有点像这样 <ul class="sortable"> <li id="item1"> <span class="grab"></span> <!-- More stuff --> </li> <li id="item2"> <span class="grab"></span> <!-- More stuff -->

我有一份菜单,看起来有点像这样

<ul class="sortable">
  <li id="item1">
    <span class="grab"></span>
    <!-- More stuff -->
  </li>
  <li id="item2">
    <span class="grab"></span>
    <!-- More stuff -->
    <ul>
       <!-- Submenu Links -->
    </ul>
  </li>
  <li id="item3">
    <span class="grab"></span>
    <!-- More stuff -->
    <ul>
       <!-- Submenu Links -->
    </ul>
  </li>
</ul>
我相当确信beforeStop是正确的函数。有人知道我怎样才能做到这一点吗?我不介意添加一点额外的html来实现它

如有任何帮助/建议,将不胜感激

 $('.sortable').sortable({
        handle: '.grab',
        items: ".link",
        connectWith: '.sortable',
        stop: function(event, ui) {
            if (!$('.prompt.saveOrder').length) {
                $('.prompt').remove();
                $('.content').prepend('<p class="prompt"><a href="' + window.location.pathname + '" class="saveOrder">Click here to save the order of your items</a></p>');
            }
        },
        beforeStop: function(event, ui) {}
    });

尝试将项目:li:not.no-sort更改为项目:li:not.no-sort,这可能会起作用。可以进行样本分析:
 $('.sortable').sortable({
        handle: '.grab',
        items: ".link",
        connectWith: '.sortable',
        stop: function(event, ui) {
            if (!$('.prompt.saveOrder').length) {
                $('.prompt').remove();
                $('.content').prepend('<p class="prompt"><a href="' + window.location.pathname + '" class="saveOrder">Click here to save the order of your items</a></p>');
            }
        },
        beforeStop: function(event, ui) {}
    });