jquery function: how to get this element id?

jquery function: how to get this element id?

Hi guys,
i'm trying to do a drag and drop...,practically a newbie to jquery & all

basically i have a list of draggable objects and a container(that these draggable objects can be dropped into)

all i want to do is whenever i drop one of the objects onto the container, an alert would pop, "you have dropped "item X" into the container".

i got the object moving but alerting the user seems to be a problem. anyone see what i'm doing wrong or what i'm not doin

code below



  1. <HTML>
  2. <HEAD>
  3.     <script type="text/javascript"
  4.         src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  5.     <script type="text/javascript"
  6.         src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
  7. </HEAD>
  8. <BODY>
  9.     <DIV id="fbox"  class="movable" style="width:150px;height:150px;background-color:red;border:1px solid #999999"> &nbsp; </DIV>
  10. <DIV id="sbox" class="movable" style="width:150px;height:150px;background-color:red;border:1px solid #999999"> &nbsp; </DIV>
  11. <DIV id="container" style="width:150px;height:150px;background-color:blue;border:1px solid #999999"> &nbsp; </DIV>
  12.     <SCRIPT TYPE="text/javascript">
  13. var dragObject = null; //object we can drag
  14.     $(document).ready(function(){
  15.         $(".movable").draggable(
  16. //{
  17. // dragObject=this;
  18. //}
  19. );
  20. $(".movable").draggable();
  21. $("#container").droppable(
  22. {
  23. drop: alertUser
  24. }
  25. );
  26. function alertUser()
  27. {
  28. alert('you dropped ' + dragObject.id); //getting undefined here
  29. }
  30. $( ".movable" ).bind( "drag", function(event, ui) {
  31. dragObject=ui;
  32. });
  33.     });
  34.     </SCRIPT>
  35.  
  36. </BODY>
  37. </HTML>
any suggestion would be greatly appreciated