简体   繁体   English

jQuery UI可拖动元素占位符

[英]jquery UI draggable element placeholder

I'm trying to add a draggable image wrap inside a <div> to a content editable <div> . 我试图将<div>中的可拖动图像换行添加到内容可编辑的<div> My problem is when I make the <div> draggable; 我的问题是当我使<div>可拖动时; it keeps the place holder. 它保留了占位符。 Space is reserved even if I moved the object, and I want to disable that. 即使我移动了对象也保留了空间,但我想禁用它。 How can I do it? 我该怎么做?

This is my code: 这是我的代码:

var cont = $('<div/>').draggable().attr('contenteditable',false);
var img = $('<img/>').attr('src',file.url).attr('height','100px').attr('width','150px');

img.appendTo(cont);
cont.appendTo('#front');
img.resizable(); 

Would need some more code (html) to test this, but offhand I'd say try one of the following: 需要更多代码(html)进行测试,但是我要立即尝试以下方法之一:

1) try setting the helper property to original: $('').draggable({helper:'original'}); 1)尝试将helper属性设置为原始属性: $('').draggable({helper:'original'}); 2) try setting your draggable as a sortable with of course helper at original: $('').sortable({helper:'original'}); 2)尝试将您的可拖动对象设置为可排序对象,当然还有原始的辅助对象: $('').sortable({helper:'original'});

Also I don't see where you've connected your drag and drop zones, use the {connectWith: '.dropzone'} when you initiate your system. 另外,我也看不到您将拖放区域连接到的位置,请在启动系统时使用{connectWith:'.dropzone'}。

I'd like to actually try it out before I tell you what to do, but that's what I'd try first. 在告诉您该怎么做之前,我想先尝试一下,但这是我首先要尝试的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM