| 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 Sortable - Handle empty lists</title> |
| 7 | <link rel="stylesheet" href="../../themes/base/all.css"> |
| 8 | <link rel="stylesheet" href="../demos.css"> |
| 9 | <style> |
| 10 | #sortable1, #sortable2, #sortable3 { list-style-type: none; margin: 0; float: left; margin-right: 10px; background: #eee; padding: 5px; width: 143px;} |
| 11 | #sortable1 li, #sortable2 li, #sortable3 li { margin: 5px; padding: 5px; font-size: 1.2em; width: 120px; } |
| 12 | </style> |
| 13 | <script src="../../external/requirejs/require.js"></script> |
| 14 | <script src="../bootstrap.js" data-modules="disable-selection"> |
| 15 | $( "ul.droptrue" ).sortable({ |
| 16 | connectWith: "ul" |
| 17 | }); |
| 18 | |
| 19 | $( "ul.dropfalse" ).sortable({ |
| 20 | connectWith: "ul", |
| 21 | dropOnEmpty: false |
| 22 | }); |
| 23 | |
| 24 | $( "#sortable1, #sortable2, #sortable3" ).disableSelection(); |
| 25 | </script> |
| 26 | </head> |
| 27 | <body> |
| 28 | |
| 29 | <ul id="sortable1" class='droptrue'> |
| 30 | <li class="ui-state-default">Can be dropped..</li> |
| 31 | <li class="ui-state-default">..on an empty list</li> |
| 32 | <li class="ui-state-default">Item 3</li> |
| 33 | <li class="ui-state-default">Item 4</li> |
| 34 | <li class="ui-state-default">Item 5</li> |
| 35 | </ul> |
| 36 | |
| 37 | <ul id="sortable2" class='dropfalse'> |
| 38 | <li class="ui-state-highlight">Cannot be dropped..</li> |
| 39 | <li class="ui-state-highlight">..on an empty list</li> |
| 40 | <li class="ui-state-highlight">Item 3</li> |
| 41 | <li class="ui-state-highlight">Item 4</li> |
| 42 | <li class="ui-state-highlight">Item 5</li> |
| 43 | </ul> |
| 44 | |
| 45 | <ul id="sortable3" class='droptrue'> |
| 46 | </ul> |
| 47 | |
| 48 | <br style="clear:both"> |
| 49 | |
| 50 | <div class="demo-description"> |
| 51 | <p> |
| 52 | Prevent all items in a list from being dropped into a separate, empty list |
| 53 | using the <code>dropOnEmpty</code> option set to <code>false</code>. By default, |
| 54 | sortable items can be dropped on empty lists. |
| 55 | </p> |
| 56 | </div> |
| 57 | </body> |
| 58 | </html> |