For some reason the placeholder for my sortable items is about 10px. All my sortable items have different heights. How can I change the height of each placeholder to match the item being moved?

推荐答案

I usually solve this by binding a callback that sets the height of the placeholder to the height of the item being sorted to the start event. It's a simple solution that gives you fine-grained control over how you want your placeholder to be displayed.

$( ".column" ).sortable({
    connectWith: ".column",
    start: function(e, ui){
        ui.placeholder.height(ui.item.height());
    }
});

See updated test case

Jquery相关问答推荐

将选定2个AJAX结果显示到模板中

子 li 元素的点击事件

Jquery $(this) 子 Select 器

当输入值以编程方式更改时触发更改事件?

如何从 jQuery 转到 React.js?

jquery克隆div并将其附加在特定div之后

在文本框中的最后一个字符之后设置焦点

$.each() 与 for() 循环 - 和性能

javascript:无效(0); vs 返回 false vs preventDefault()

在 for 循环中分配点击处理程序

如何使用 jQuery 的 getJSON() 方法传递请求标头?

是否可以使用 javascript 打开一个弹出窗口,然后检测用户何时关闭它?

jQuery 中的 $this 与 $(this)

jQuery JSON到字符串?

如何使用 jQuery Select 单个子元素?

jQuery 序列化不注册复选框

javascript 正则表达式用于包含至少 8 个字符、1 个数字、1 个大写和 1 个小写的密码

jQuery - 使用发布数据重定向

使用 Typescript 时如何停止类型 JQuery 上不存在属性语法错误?

在 jQuery 中 Select 后代元素的最快方法是什么?