1 | <!doctype html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <title>jQuery UI Droppable - Visual feedback</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: 90px; height: 90px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
|
---|
15 | #droppable, #droppable2 { width: 120px; height: 120px; padding: 0.5em; float: left; margin: 10px; }
|
---|
16 | </style>
|
---|
17 | <script type="text/javascript">
|
---|
18 | $(function() {
|
---|
19 | $("#draggable").draggable();
|
---|
20 | $("#droppable").droppable({
|
---|
21 | hoverClass: 'ui-state-active',
|
---|
22 | drop: function(event, ui) {
|
---|
23 | $(this).addClass('ui-state-highlight').find('p').html('Dropped!');
|
---|
24 | }
|
---|
25 | });
|
---|
26 |
|
---|
27 | $("#draggable2").draggable();
|
---|
28 | $("#droppable2").droppable({
|
---|
29 | accept: "#draggable2",
|
---|
30 | activeClass: 'ui-state-hover',
|
---|
31 | drop: function(event, ui) {
|
---|
32 | $(this).addClass('ui-state-highlight').find('p').html('Dropped!');
|
---|
33 | }
|
---|
34 | });
|
---|
35 |
|
---|
36 | });
|
---|
37 | </script>
|
---|
38 | </head>
|
---|
39 | <body>
|
---|
40 | <div class="demo">
|
---|
41 |
|
---|
42 | <h3 class="docs">Feedback on hover:</h3>
|
---|
43 |
|
---|
44 | <div id="draggable" class="ui-widget-content">
|
---|
45 | <p>Drag me to my target</p>
|
---|
46 | </div>
|
---|
47 |
|
---|
48 | <div id="droppable" class="ui-widget-header">
|
---|
49 | <p>Drop here</p>
|
---|
50 | </div>
|
---|
51 |
|
---|
52 | <h3 class="docs">Feedback on activating draggable:</h3>
|
---|
53 |
|
---|
54 | <div id="draggable2" class="ui-widget-content">
|
---|
55 | <p>Drag me to my target</p>
|
---|
56 | </div>
|
---|
57 |
|
---|
58 | <div id="droppable2" class="ui-widget-header">
|
---|
59 | <p>Drop here</p>
|
---|
60 | </div>
|
---|
61 |
|
---|
62 | <!-- add active class demo -->
|
---|
63 |
|
---|
64 | </div><!-- End demo -->
|
---|
65 |
|
---|
66 | <div class="demo-description">
|
---|
67 |
|
---|
68 | <p>Change the droppable's appearance on hover, or when the droppable is active (an acceptable draggable is dropped on it). Use the <code>hoverClass</code> or <code>activeClass</code> options to specify respective classes.</p>
|
---|
69 |
|
---|
70 | </div><!-- End demo-description -->
|
---|
71 | </body>
|
---|
72 | </html>
|
---|