0
也许你能帮我一下,我想创建一个带有可拖动(不是克隆)div的列,我可以把它放到容器中,它由四个div(bootstrap col-md-3 )。可拖曳元素有两种尺寸:col-md-3或col-md-6。我发现类似的东西(http://jsfiddle.net/py3DE/),但我不能重写它才能正常工作用jQuery拖放元素
$(".source .item").draggable({ revert: "invalid", appendTo: 'body', helper: 'clone',
start: function(ev, ui){ ui.helper.width($(this).width()); } // ensure helper width
});
$(".target .empty").droppable({ tolerance: 'pointer', hoverClass: 'highlight',
drop: function(ev, ui){
var item = ui.draggable;
if (!ui.draggable.closest('.empty').length) item = item.clone().draggable();// if item was dragged from the source list - clone it
this.innerHTML = ''; // clean the placeholder
item.css({ top: 0, left: 0 }).appendTo(this); // append item to placeholder
}
});
$(".target").on('click', '.closer', function(){
var item = $(this).closest('.item');
item.fadeTo(200, 0, function(){ item.remove(); })
});
伟大的,但我怎么能求解带与元素的宽度引导的问题? – jdoe