tripwater
07-11-2008, 07:05 PM
I am trying to implement the drag and drop into a gantt chart. I have a list of tasks with task
IDs that need to be reschedule. So I have a column of tasks the just
after that I have columns of dates for the month. I want to drag a
task from one date to the next and using ajax call, update the task to
the new date.
I found demo code I am working on dragging one box to another. I was
wondering how to alert the id of the draggable on the ondrop event in
the droppable? I know how to pass in the getElementById but the
problem is that this is a dynamic list and I will not know the id of
the div in order to manually pass this into the ondrop. I will be
naming the tasks (draggables) a unique id based off their taskid out
of the database. I will be naming the date columns (droppables) after
the date for that day. So in my php for loop I will build this
dynamically. But for test purposes, if I can find out how to drag a
draggable to a droppable and it tell me the id of what I just dragged
as well as the id of what I just dropped it into, well then my work is
done...I hope :)
For example
<div class="demo" id="droppable_container">
<div id="task_1234" class="draggable">
Drag me!
</div>
<div id="drop_2008-7-11">
Drop here!
</div>
</div>
<script type="text/javascript">
var mydrag1 = new Draggable('task_1234', { scroll: window, constraint: 'horizontal', handle: 'handle' });
Droppables.add(
'drop_2008-7-11', {
accept: 'draggable',
hoverclass: 'hover',
onDrop: function()
{
alert( );//NEED TO ALERT THE ID OF DRAGGABLE AND THE ID OF DROPPABLE IT WAS DROPPED IN
$( 'droppable_demo' ).highlight();
}
} );
</script>
I hope this makes sense and thank you for any help with this.
IDs that need to be reschedule. So I have a column of tasks the just
after that I have columns of dates for the month. I want to drag a
task from one date to the next and using ajax call, update the task to
the new date.
I found demo code I am working on dragging one box to another. I was
wondering how to alert the id of the draggable on the ondrop event in
the droppable? I know how to pass in the getElementById but the
problem is that this is a dynamic list and I will not know the id of
the div in order to manually pass this into the ondrop. I will be
naming the tasks (draggables) a unique id based off their taskid out
of the database. I will be naming the date columns (droppables) after
the date for that day. So in my php for loop I will build this
dynamically. But for test purposes, if I can find out how to drag a
draggable to a droppable and it tell me the id of what I just dragged
as well as the id of what I just dropped it into, well then my work is
done...I hope :)
For example
<div class="demo" id="droppable_container">
<div id="task_1234" class="draggable">
Drag me!
</div>
<div id="drop_2008-7-11">
Drop here!
</div>
</div>
<script type="text/javascript">
var mydrag1 = new Draggable('task_1234', { scroll: window, constraint: 'horizontal', handle: 'handle' });
Droppables.add(
'drop_2008-7-11', {
accept: 'draggable',
hoverclass: 'hover',
onDrop: function()
{
alert( );//NEED TO ALERT THE ID OF DRAGGABLE AND THE ID OF DROPPABLE IT WAS DROPPED IN
$( 'droppable_demo' ).highlight();
}
} );
</script>
I hope this makes sense and thank you for any help with this.