【问题标题】:jQuery sortable child won't go into parentjQuery可排序的孩子不会进入父母
【发布时间】:2018-01-16 05:15:08
【问题描述】:

如果其中一个父母被清空(孩子转移到另一个父母),那么您将无法将孩子移回空父母。

https://jsfiddle.net/k8x7om75/

    // Sort the parents
    $(".sortMenu").sortable({
        containment: "document",
        items: "> div",
        tolerance: "pointer",
        cursor: "move",
        opacity: 0.7,
        revert: 300,
        delay: 150,
        placeholder: "menuPlaceholder",
        start: function(e, ui) {
            ui.placeholder.height(ui.helper.outerHeight());
        }
    });

    // Sort the children
    $(".menuItems").sortable({
        items: "> div",
        tolerance: "pointer",
        containment: "document",
        connectWith: '.menuItems'
    });

通常我会自己做,但我不知道 JavaScript 或它的任何风格。抱歉,如果这看起来微不足道,但我需要帮助。谢谢

【问题讨论】:

  • ...有什么问题?

标签: javascript jquery jquery-ui jquery-ui-sortable


【解决方案1】:

添加以下css:

.ui-sortable{
   padding: 5px;
 }

您正面临这个问题,因为一旦您的父容器变空,那么父容器中可排序 div 的高度就会变为 0,没有地方可以将子容器拖回其中。

如果您不想要额外的填充,则按如下方式制作 css:

 .ui-sortable{
     min-height: 10px;
  }

【讨论】:

  • 谢谢!!我选择了最小高度
猜你喜欢
  • 1970-01-01
  • 2017-06-26
  • 2011-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-22
相关资源
最近更新 更多