Ticket #4910: propagation_showgreedybug.html

File propagation_showgreedybug.html, 2.4 KB (added by iceberg901, 13 years ago)

modification of propagation.html demo showing the bug

Line 
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.3.2.js"></script>
7        <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
8        <script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script>
9        <script type="text/javascript" src="../../ui/jquery.ui.droppable.js"></script>
10        <link type="text/css" href="../demos.css" rel="stylesheet" />
11        <style type="text/css">
12        #draggable { width: 100px; height: 40px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
13        #droppable, #droppable2 { width: 230px; height: 120px; padding: 0.5em; float: left; margin: 10px; }
14        #droppable-inner, #droppable2-inner { width: 170px; height: 60px; padding: 0.5em; float: left; margin: 10px; }
15        </style>
16        <script type="text/javascript">
17        $(function() {
18
19                $("#draggable").draggable();
20
21                $("#droppable, #droppable-inner").droppable({
22                        activeClass: 'ui-state-hover',
23                        hoverClass: 'ui-state-active',
24                        drop: function(event, ui) {
25                                $(this).addClass('ui-state-highlight').find('> p').html('Dropped!');
26                                return false;
27                        }
28                });
29               
30               
31               
32                $("#droppable2, #droppable2-inner").droppable({
33                        greedy: true,
34                        activeClass: 'ui-state-hover',
35                        hoverClass: 'ui-state-active',
36                }).bind('drop', function(event, ui) {
37                        $(this).addClass('ui-state-highlight').find('> p').html('Dropped!');
38                });
39
40        });
41        </script>
42</head>
43<body>
44<div class="demo">
45       
46<div id="draggable" class="ui-widget-content">
47        <p>Drag me to my target</p>
48</div>
49
50<div id="droppable" class="ui-widget-header">
51        <p>Outer droppable</p>
52        <div id="droppable-inner" class="ui-widget-header">
53                <p>Inner droppable (not greedy)</p>
54        </div>
55</div>
56
57<div id="droppable2" class="ui-widget-header">
58        <p>Outer droppable</p>
59        <div id="droppable2-inner" class="ui-widget-header">
60                <p>Inner droppable (greedy)</p>
61        </div>
62</div>
63
64</div><!-- End demo -->
65
66<div class="demo-description">
67
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
70</div><!-- End demo-description -->
71</body>
72</html>