views:

218

answers:

1

I'm trying to figure out how to write a statement which will stop the jQuery droppable function if the the dragged element is the parent.

Basically what I have is a table, and each cell has the id of x-axis:eq+'-'+y-axis:eq. (x over-x-down). When the user drags an element to a different cell, I update the info, so if you drag from cell 3-3 to 3-4, I update the data.

However, if the user starts dragging from 3-3, and then stops dragging still within the 3-3 cell, I want to prevent the droppable function from firing.

I've been looking at using the 'accept' function, but can't figure out how to say !jQuery('td#3-3')

Here's what I've got

jQuery('div','table').draggable({axis:'y', containment: 'table'});
var cellId=jQuery(this).parents('td').attr('id');
jQuery('td','table').droppable({
           accept : !jQuery('td#'+cellId),
           drop: function(){
              jQuery.ajax({ update stuff in db});
            }

         });
+2  A: 

try

$('.myselector').droppable({ accept: 'td:not(#' + cellId +')' });
Jason
that is likely correct, but looks like it needs a bit more. when I use that code, the drop function doesn't get triggered, even when dragged onto a different cell.
pedalpete