javascript - Drop on same dragged element -
i want create jquery drag , drop below
1) can drag element class dodrag 2) can drop dodrag div called #content 3) dodrag elements should able drop older dodrag divs dropped before #content div
i did below. got issues.
$(".dodrag").draggable({ helper:"clone" }); makedroppable($("#content")); function makedroppable(elements) { console.debug(elements); $(elements).droppable({ activeclass: "ui-state-hover", hoverclass: "ui-state-active", drop: function (event, ui) { var uuid = guid(); $(this).append("<div style='border:2px solid;height:50px;width:400px;' id='" + uuid + "'>drop</div>"); makedroppable($("#" + uuid)); return false; } }); }
what happened drop event calling multiple times.
can me on please
finally found answer.
what had add greedy:true
elements.droppable({ greedy: true, activeclass: "ui-state-hover", hoverclass: "ui-state-active", drop: function (event, ui) { console.debug($(this)); var uuid = guid(); $(this).append("<div style='border:2px solid;height:50px;width:400px;' id='" + uuid + "'>drop</div>"); makedroppable($("#" + uuid)); return false; } });
Comments
Post a Comment