2012-09-10 15:33:46 +00:00
<!doctype html>
2009-01-16 21:46:30 +00:00
< html lang = "en" >
< head >
2010-09-10 13:38:42 +00:00
< meta charset = "utf-8" >
2009-01-16 21:46:30 +00:00
< title > jQuery UI Droppable - Prevent propagation< / title >
2013-12-02 18:36:12 +00:00
< link rel = "stylesheet" href = "../../themes/base/all.css" >
2010-09-10 13:38:42 +00:00
< link rel = "stylesheet" href = "../demos.css" >
< style >
2009-02-27 16:57:26 +00:00
#draggable { width: 100px; height: 40px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
2009-01-16 21:46:30 +00:00
#droppable, #droppable2 { width: 230px; height: 120px; padding: 0.5em; float: left; margin: 10px; }
#droppable-inner, #droppable2-inner { width: 170px; height: 60px; padding: 0.5em; float: left; margin: 10px; }
< / style >
2015-06-30 21:18:16 +00:00
< script src = "../../external/requirejs/require.js" > < / script >
< script src = "../bootstrap.js" >
2010-09-10 13:38:42 +00:00
$( "#draggable" ).draggable();
2009-01-16 21:46:30 +00:00
2010-09-10 13:38:42 +00:00
$( "#droppable, #droppable-inner" ).droppable({
2015-01-01 17:11:06 +00:00
classes: {
"ui-droppable-active": "ui-state-active",
"ui-droppable-hover": "ui-state-hover"
},
2010-09-10 13:38:42 +00:00
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "> p" )
.html( "Dropped!" );
2009-01-20 13:36:29 +00:00
return false;
2009-01-16 21:46:30 +00:00
}
});
2010-09-10 13:38:42 +00:00
$( "#droppable2, #droppable2-inner" ).droppable({
2009-01-16 21:46:30 +00:00
greedy: true,
2015-01-01 17:11:06 +00:00
classes: {
"ui-droppable-active": "ui-state-active",
"ui-droppable-hover": "ui-state-hover"
},
2010-09-10 13:38:42 +00:00
drop: function( event, ui ) {
$( this )
.addClass( "ui-state-highlight" )
.find( "> p" )
.html( "Dropped!" );
2009-01-16 21:46:30 +00:00
}
});
< / script >
< / head >
< body >
2010-09-10 13:38:42 +00:00
2009-01-16 21:46:30 +00:00
< div id = "draggable" class = "ui-widget-content" >
< p > Drag me to my target< / p >
< / div >
< div id = "droppable" class = "ui-widget-header" >
< p > Outer droppable< / p >
< div id = "droppable-inner" class = "ui-widget-header" >
< p > Inner droppable (not greedy)< / p >
< / div >
< / div >
< div id = "droppable2" class = "ui-widget-header" >
< p > Outer droppable< / p >
< div id = "droppable2-inner" class = "ui-widget-header" >
< p > Inner droppable (greedy)< / p >
< / div >
< / div >
2010-09-10 13:38:42 +00:00
< div class = "demo-description" >
< 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 >
2012-09-10 15:33:46 +00:00
< / div >
2009-01-16 21:46:30 +00:00
< / body >
< / html >