1

I'm making a document list, and I need to stop a draggable element being accepted by its parent. The option is set like:

$( ".onedoc" ).droppable({
accept: ".onedoc"
});

but I want the droppable not to accept its immediate children. The problem is since it's a nested list, the parents and children have the same classes, so I need to do something like

accept: $(".onedoc").not($(this).children())

but of course this doesn't work.

DMIL
  • 693
  • 3
  • 7
  • 18

1 Answers1

4

Maybe because accept: is looking for a selector and your are providing it with a jQuery object?

How about you provide it with a function?

$(".onedoc").droppable({
    accept: function (elem) {
        // check elem here for being a child and return false
        return !$(this).has(elem).length;
    }
});
U.P
  • 7,357
  • 7
  • 39
  • 61
  • Error: Object doesn't support property or method 'has'. Was I supposed to change something? This is a bit beyond me, I don't know how a function returning true/false can help in this case. I need to accept elements of .onedoc except those that are the immediate children of the element being a droppable in this case (so users can't drop an element on or see hoverClass of its parent). – DMIL Jun 18 '12 at 17:11