1 | <!doctype html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <title>jQuery UI Droppable - Prevent propagation</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 { width: 100px; height: 40px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
|
---|
15 | #droppable, #droppable2 { width: 230px; height: 120px; padding: 0.5em; float: left; margin: 10px; }
|
---|
16 | #droppable-inner, #droppable2-inner { width: 170px; height: 60px; padding: 0.5em; float: left; margin: 10px; }
|
---|
17 | </style>
|
---|
18 | <script type="text/javascript">
|
---|
19 | $(function() {
|
---|
20 |
|
---|
21 | $("#draggable").draggable();
|
---|
22 |
|
---|
23 | $("#droppable, #droppable-inner").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 | return false;
|
---|
29 | }
|
---|
30 | });
|
---|
31 |
|
---|
32 | $("#droppable2, #droppable2-inner").droppable({
|
---|
33 | greedy: true,
|
---|
34 | activeClass: 'ui-state-hover',
|
---|
35 | hoverClass: 'ui-state-active',
|
---|
36 | drop: function(event, ui) {
|
---|
37 | $(this).addClass('ui-state-highlight').find('> p').html('Dropped!');
|
---|
38 | }
|
---|
39 | });
|
---|
40 |
|
---|
41 | });
|
---|
42 | </script>
|
---|
43 | </head>
|
---|
44 | <body>
|
---|
45 | <div class="demo">
|
---|
46 |
|
---|
47 | <div id="draggable" class="ui-widget-content">
|
---|
48 | <p>Drag me to my target</p>
|
---|
49 | </div>
|
---|
50 |
|
---|
51 | <div id="droppable" class="ui-widget-header">
|
---|
52 | <p>Outer droppable</p>
|
---|
53 | <div id="droppable-inner" class="ui-widget-header">
|
---|
54 | <p>Inner droppable (not greedy)</p>
|
---|
55 | </div>
|
---|
56 | </div>
|
---|
57 |
|
---|
58 | <div id="droppable2" class="ui-widget-header">
|
---|
59 | <p>Outer droppable</p>
|
---|
60 | <div id="droppable2-inner" class="ui-widget-header">
|
---|
61 | <p>Inner droppable (greedy)</p>
|
---|
62 | </div>
|
---|
63 | </div>
|
---|
64 |
|
---|
65 | </div><!-- End demo -->
|
---|
66 |
|
---|
67 | <div class="demo-description">
|
---|
68 |
|
---|
69 | <p>When working with nested droppables — for example, you may have an editable directory structure displayed as a tree, with folder and document nodes — the <code>greedy</code> option set to true prevents event propagation when a draggable is dropped on a child node (droppable).</p>
|
---|
70 |
|
---|
71 | </div><!-- End demo-description -->
|
---|
72 | </body>
|
---|
73 | </html>
|
---|