javascript - When dragging onto a table, how do you tell which row got dropped onto? -
i hoping use 'draggable' , 'droppable' functions of jquery-ui drag data 1 table another.
i hoping able keep track of cell gets dragged (specifically, x/y index), , though this object droppable function returns lists cellindex, contains column (x) value, i've had less luck finding row got dropped onto (the y).
how can tell row dropped on?
i following:
- use
drop event - find dropped object using
$(this)orevent.target - find
.closest()table row(tr) compare table's rows using
.index()$('#mappingchar td').droppable({ hoverclass: "ui-state-hover", drop: function (event, ui) { var dropped = $(this), droppedrow = dropped.closest('tr'); console.log(droppedrow.index()); } });
demo: http://jsfiddle.net/dirtyd77/xckdx/3/
hope helps , let me know if have questions!
Comments
Post a Comment