1 | <!doctype html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <title>jQuery UI Droppable - Revert draggable position</title>
|
---|
5 | <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
|
---|
6 | <script type="text/javascript" src="../../jquery-1.4.1.js"></script>
|
---|
7 | <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
|
---|
8 | <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
|
---|
9 | <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script>
|
---|
10 | <script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script>
|
---|
11 | <script type="text/javascript" src="../../ui/jquery.ui.droppable.js"></script>
|
---|
12 | <link type="text/css" href="../demos.css" rel="stylesheet" />
|
---|
13 | <style type="text/css">
|
---|
14 | #draggable, #draggable2 { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
|
---|
15 | #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }
|
---|
16 | </style>
|
---|
17 | <script type="text/javascript">
|
---|
18 | $(function() {
|
---|
19 |
|
---|
20 | $("#draggable").draggable({ revert: 'valid' });
|
---|
21 | $("#draggable2").draggable({ revert: 'invalid' });
|
---|
22 |
|
---|
23 | $("#droppable").droppable({
|
---|
24 | activeClass: 'ui-state-hover',
|
---|
25 | hoverClass: 'ui-state-active',
|
---|
26 | drop: function(event, ui) {
|
---|
27 | $(this).addClass('ui-state-highlight').find('p').html('Dropped!');
|
---|
28 | }
|
---|
29 | });
|
---|
30 |
|
---|
31 | });
|
---|
32 | </script>
|
---|
33 | </head>
|
---|
34 | <body>
|
---|
35 | <div class="demo">
|
---|
36 |
|
---|
37 | <div id="draggable" class="ui-widget-content">
|
---|
38 | <p>I revert when I'm dropped</p>
|
---|
39 | </div>
|
---|
40 |
|
---|
41 | <div id="draggable2" class="ui-widget-content">
|
---|
42 | <p>I revert when I'm not dropped</p>
|
---|
43 | </div>
|
---|
44 |
|
---|
45 | <div id="droppable" class="ui-widget-header">
|
---|
46 | <p>Drop me here</p>
|
---|
47 | </div>
|
---|
48 |
|
---|
49 | </div><!-- End demo -->
|
---|
50 |
|
---|
51 | <div class="demo-description">
|
---|
52 |
|
---|
53 | <p>Return the draggable (or it's helper) to its original location when dragging stops with the boolean <code>revert</code> option set on the draggable.</p>
|
---|
54 |
|
---|
55 | </div><!-- End demo-description -->
|
---|
56 | </body>
|
---|
57 | </html>
|
---|