jQuery 可拖动,留下克隆的 html
我正在使用 jQuery UI; Draggable http://jqueryui.com/demos/draggable 像这样调用:
$(document).ready(function(){
$("#side_bar").sortable({
revert: true
});
$(".draggable").draggable({
containment: 'parent',
hascroll: true,
handle: 'div.box_header',
scrollSensitivity: 100,
scrollSpeed: 100,
axis: 'y',
connectToSortable: '#side_bar',
helper: 'clone',
opacity: 0.35
}); });
您可以看到html结构在http://www.sarsclan.co.uk(右侧栏区域)。
它似乎在拖动时创建了一个透明的克隆,但是当您放下时,它会将可拖动的 div 放在正确的位置,但将原始 div 保留在原来的位置,只是将原始 div 的克隆附加到新位置的 dom 上。
I am using jQuery UI; Draggable http://jqueryui.com/demos/draggable invoked like this:
$(document).ready(function(){
$("#side_bar").sortable({
revert: true
});
$(".draggable").draggable({
containment: 'parent',
hascroll: true,
handle: 'div.box_header',
scrollSensitivity: 100,
scrollSpeed: 100,
axis: 'y',
connectToSortable: '#side_bar',
helper: 'clone',
opacity: 0.35
}); });
You can see the html structure on http://www.sarsclan.co.uk (right side bar area).
It seems to create a transparant clone as your dragging, but when you drop it puts the draggable div in the right place, but leaves the original div in it's place and just appends the dom with a clone of that original div in its new place.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,jqueryui Sortable 上的演示没有显示额外的
draggable
调用: http://jqueryui.com/demos/sortable/。您是否尝试过仅使用sortable
调用?编辑:我可以看到您的代码类似于 jqueryui 网站上的“Draggable + Sortable”示例。但是,该示例始终克隆顶部的元素并将克隆插入到可排序列表中,因此这不是您想要实现的目标。
The demos on jqueryui Sortable show no extra
draggable
call, as far as I can see: http://jqueryui.com/demos/sortable/. Have you tried to do with asortable
call only?EDIT: I can see that your code is similar to the "Draggable + Sortable" example on the jqueryui site. However, that example always clones the element at the top and inserts the clone into the sortable list, so that's not what you want to achieve.
你真的想拥有“helper:'clone'”吗?如果删除它会发生什么?
Do you really mean to have " helper: ' clone' " ? What happens if you remove it?