0

Vielleicht können Sie mir helfen, ich möchte eine Spalte mit Dragable (nicht klonen) divs, die ich in den Container, der aus vier Divs (Bootstrap Col-md-3). Dragable Elemente haben zwei Größen: Col-MD-3 oder Col-MD-6. Ich fand etwas ähnliches (http://jsfiddle.net/py3DE/), aber ich kann es nicht umschreiben richtigDrag & Drop-Elemente mit 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(); }) 
}); 

Antwort

0

, wenn Sie aktualisieren ‚item.clone(). Ziehbar()‘ zu ‚item.draggable()‘ zu arbeiten, wird es nicht Klon .

js code

if (!ui.draggable.closest('.empty').length) item = item.draggable() 
+0

groß, aber wie kann ich sovle Bootstrap-Problem mit der Breite des Elements? – jdoe