0

I need to find a droppable control when the Draggable stop event is running, and I got an ID. Is this possible? So basically my idea is this: When the "out" function's running, I store the dropId. Then if an item is being reverted, I need to set that old Droppable to accept only the reverted Draggable.

this is part of my code:

        var dropId;
        $('.droppable').droppable
        ({
            hoverClass: "ui-state-active",
            drop: itemDrop,
            out: function (event, ui) {
                $(this).droppable('option', 'accept', '.draggable');
                ui.draggable.zIndex = 6000
                dropId = $(this).attr("id");
            },

        $('.draggable').draggable
        ({
            revert: 'invalid',
            cursor: 'move',
            zIndex: 5000,
            stop: function (event, ui) {
                var draggableId = $(this).attr("id");
                if (event.reverted) { 
                   // dropID.droppable('option', 'accept', draggableId), something lite this
                }
            }

        });

My itemDrop function basically updates the database, and set this: $(this).droppable('option', 'accept', ui.draggable);

Which is somewhat what I am after for when an item is being reverted.

Hope I am somewhat clear! If not, let me know.

Thanks!

Zoizaite
  • 11
  • 4

1 Answers1

1

You need to make small changes in your code, check this

  $("#" + dropId).droppable('option', 'accept', "#" + draggableId);
Amar
  • 1,906
  • 2
  • 16
  • 26
  • Thanks for the answer. I ended up using this method, saving the object itself, not just its ID: dropId = $(this); The problem was that the out function always trigger whenever the user leaves a droppable. I just want to set dropID to the first one. So i used a counter: if (counter == 0) { dropId = $(this); counter += 1; } Then, when a draggable was dropped, or reverted: counter = 0; Hope this can help others too! Now solved. – Zoizaite Nov 20 '12 at 09:32