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?

js fiddle link

i following:

  • use drop event
  • find dropped object using $(this) or event.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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -