Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery droppable get draggable id

I want to get dragged id when i dropped to the certain div

  Drag  <ul id="demo" > 
         <li id="1" ></li>
         <li id="2" ></li>
        <li id="3" ></li>
        </ul>

         <div class="drop"> drop here!! </div>

JQUERY

  $(".drop").droppable({ 
                drop: function(event, ui) {

      // i need to get dragged id (note:able to  drag multiple ids)

        1,2,3..     

            }       
            });

Please help me out!! Thnks

like image 871
Akshay Avatar asked May 19 '12 14:05

Akshay


1 Answers

As they says in jQuery UI dropable doc

All callbacks receive two arguments: The original browser event and a prepared ui object, view below for a documentation of this object (if you name your second argument 'ui'):

ui.draggable - current draggable element, a jQuery object.
ui.helper - current draggable helper, a jQuery object
ui.position - current position of the draggable helper { top: , left: }
ui.offset - current absolute position of the draggable helper { top: , left: }

ui.draggable is the element being dropped as a jQuery object.

So You can get the ID using ui.draggable.prop('id')

like image 130
Prasenjit Kumar Nag Avatar answered Sep 22 '22 06:09

Prasenjit Kumar Nag