Add dragging stopped event handler : UI Draggable « jQuery « JavaScript DHTML






Add dragging stopped event handler

 
<html lang="en">
<head>
  <title></title>
  <link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
  <script type="text/javascript" src="js/ui/ui.core.js"></script>
  <script type="text/javascript" src="js/ui/ui.draggable.js"></script>
  <link type="text/css" href="js/demos.css" rel="stylesheet" />
  <script type="text/javascript">
    $(function() {
      var dragOpts = {
        helper: "clone",  
        stop: getNewPos
      };
      
      function getNewPos(e, ui) {
      
        e.stopPropagation();      
        alert(ui.position.top + "px from the top, " + ui.position.left + "px to the left of the original object.");
        alert(ui.absolutePosition.top + "px from the top, and " + ui.absolutePosition.left + "px to the left relative to the page.");
      }
    
    
      $("#drag").draggable(dragOpts);
    });
  </script>
</head>
<body>
    <div id="container">
          <div id="drag">asdf</div>
    </div>

</body>
</html>

   
  








Related examples in the same category

1.jQuery UI Draggable - Constrain movement
2.jQuery UI Draggable - Cursor style
3.jQuery UI Draggable - Default functionality
4.jQuery UI Draggable - Delay start
5.jQuery UI Draggable - Events
6.jQuery UI Draggable - Handles
7.jQuery UI Draggable - Revert position
8.jQuery UI Draggable - Auto-scroll
9.jQuery UI Draggable - Snap to element or grid
10.jQuery UI Draggable + Sortable
11.jQuery UI Draggable - Visual feedback
12.Change cursor for draggable tag
13.Set cursor position for the draggable
14.Can only drag along with axis y
15.Drag delay
16.Drag along a grid
17.Add border to the draggable
18.Only draggable inside parent
19.revert: true (fly back)
20.Snap to another
21.start and stop events
22.Disable, enable and destroy the draggable object
23.Set the handles for all directions
24.Add knobHandles