draggable - Using JQuery to let the user drag and drop text into a specific DIV -
so, i'm trying use draggable , droppable functions create this. javascript this:
$(init); function init() { $('#headerdrag').draggable({ cursor: 'move', revert: true, containment: '#content2' }); $('#header').droppable({ accept: '#headerdrag', drop: handledropevent }); } function handledropevent(event, ui) { var draggable = ui.draggable; }
the divs:
<div id="headerdrag"> header </div> <div id = "header">drop me here</div>
i can drag div called "headerdrag" when try dropping onto div "header", doesn't work , "headerdrag" reverts original place. how can make work drop onto div "header", not onto other divs might create in future, onto div called "header".
i'm not exacly sure want happend here attempt:
$('#headerdrag').draggable({ cursor: 'move', revert: true }); $('#header').droppable({ accept: '#headerdrag', drop: handledropevent }); function handledropevent(event, ui) { $(this).append($('#headerdrag')); }
jsfiddle: http://jsfiddle.net/kw3tb/
Comments
Post a Comment