Debian Codegraph @

demos/droppable/propagation.html

raw
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>jQuery UI Droppable - Prevent propagation</title>
7 <link rel="stylesheet" href="../../themes/base/all.css">
8 <link rel="stylesheet" href="../demos.css">
9 <style>
10 #draggable { width: 100px; height: 40px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
11 #droppable, #droppable2 { width: 230px; height: 120px; padding: 0.5em; float: left; margin: 10px; }
12 #droppable-inner, #droppable2-inner { width: 170px; height: 60px; padding: 0.5em; float: left; margin: 10px; }
13 </style>
14 <script src="../../external/requirejs/require.js"></script>
15 <script src="../bootstrap.js">
16 $( "#draggable" ).draggable();
17
18 $( "#droppable, #droppable-inner" ).droppable({
19 classes: {
20 "ui-droppable-active": "ui-state-active",
21 "ui-droppable-hover": "ui-state-hover"
22 },
23 drop: function( event, ui ) {
24 $( this )
25 .addClass( "ui-state-highlight" )
26 .find( "> p" )
27 .html( "Dropped!" );
28 return false;
29 }
30 });
31
32 $( "#droppable2, #droppable2-inner" ).droppable({
33 greedy: true,
34 classes: {
35 "ui-droppable-active": "ui-state-active",
36 "ui-droppable-hover": "ui-state-hover"
37 },
38 drop: function( event, ui ) {
39 $( this )
40 .addClass( "ui-state-highlight" )
41 .find( "> p" )
42 .html( "Dropped!" );
43 }
44 });
45 </script>
46 </head>
47 <body>
48
49 <div id="draggable" class="ui-widget-content">
50 <p>Drag me to my target</p>
51 </div>
52
53 <div id="droppable" class="ui-widget-header">
54 <p>Outer droppable</p>
55 <div id="droppable-inner" class="ui-widget-header">
56 <p>Inner droppable (not greedy)</p>
57 </div>
58 </div>
59
60 <div id="droppable2" class="ui-widget-header">
61 <p>Outer droppable</p>
62 <div id="droppable2-inner" class="ui-widget-header">
63 <p>Inner droppable (greedy)</p>
64 </div>
65 </div>
66
67 <div class="demo-description">
68 <p>When working with nested droppables &#8212; for example, you may have an editable directory structure displayed as a tree, with folder and document nodes &#8212; the <code>greedy</code> option set to true prevents event propagation when a draggable is dropped on a child node (droppable).</p>
69 </div>
70 </body>
71 </html>