Here is a little code that I used for my projects.
Html:
<div class="N_COn_USER" name="moh1234"> <img class="delople" src="_files/us.png" /> </div> <div class="N_COn_USER" name="demo1234"> <img class="delople" src="_files/us.png" /> </div> <div class="N_COn_USER" name="foo1234"> <img class="delople" src="_files/us.png" /> </div>
JQuery:
$(document).ready(function() { var id ; id = $(".N_COn_USER").draggable({ // the draggable div revert: true, helper: "clone", start: function(event, ui) { id = $(this).attr("name"); // we name each draggable item with its ID or any unique identifier. And here, we grab that value .. } }).attr("name"); $("#dropable_file").droppable({ tolerance: 'touch', drop: function() { var agree=confirm('Permantly delete '+ id2 +"?"); if (agree) { $.ajax({ url: 'unfollow', data: 'u=' + id, // we send that ID to a processing page controller type: 'post', success: function(msg){ if(msg == 'bad') // Message Sent, check and redirect { // and direct to the success page $("#msgbox").html('').addClass('good'); $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox { //add message and change the class of the box and start fading $(this).html('Tcxfgg').removeClass().addClass('error').fadeTo(300,1); // if not deleted, show an error! }); } else // if everything went perfectly { $("div[name="+id+"]").fadeOut("slow"); // the item with that unique name gets faded out on success. $("span[name="+id+"]").fadeOut("slow"); // picture of it also should have its own name if it lives outside that DIV. } } }); } else { return false; } } }); });
I hope this helps.
Faisal
source share