1 | <!DOCTYPE html> |
---|
2 | <html lang="en"> |
---|
3 | <head> |
---|
4 | <meta charset="utf-8"> |
---|
5 | <title>jQuery UI Sortable - Handle empty lists</title> |
---|
6 | <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css"> |
---|
7 | <script src="../../jquery-1.6.2.js"></script> |
---|
8 | <script src="../../ui/jquery.ui.core.js"></script> |
---|
9 | <script src="../../ui/jquery.ui.widget.js"></script> |
---|
10 | <script src="../../ui/jquery.ui.mouse.js"></script> |
---|
11 | <script src="../../ui/jquery.ui.sortable.js"></script> |
---|
12 | <link rel="stylesheet" href="../demos.css"> |
---|
13 | <style> |
---|
14 | #sortable1, #sortable2, #sortable3 { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; background: #eee; padding: 5px; width: 143px;} |
---|
15 | #sortable1 li, #sortable2 li, #sortable3 li { margin: 5px; padding: 5px; font-size: 1.2em; width: 120px; } |
---|
16 | </style> |
---|
17 | <script> |
---|
18 | $(function() { |
---|
19 | $( "ul.droptrue" ).sortable({ |
---|
20 | connectWith: "ul" |
---|
21 | }); |
---|
22 | |
---|
23 | $( "ul.dropfalse" ).sortable({ |
---|
24 | connectWith: "ul", |
---|
25 | dropOnEmpty: false |
---|
26 | }); |
---|
27 | |
---|
28 | $( "#sortable1, #sortable2, #sortable3" ).disableSelection(); |
---|
29 | }); |
---|
30 | </script> |
---|
31 | </head> |
---|
32 | <body> |
---|
33 | <div class="demo"> |
---|
34 | |
---|
35 | <ul id="sortable1" class='droptrue'> |
---|
36 | <li class="ui-state-default">Can be dropped..</li> |
---|
37 | <li class="ui-state-default">..on an empty list</li> |
---|
38 | <li class="ui-state-default">Item 3</li> |
---|
39 | <li class="ui-state-default">Item 4</li> |
---|
40 | <li class="ui-state-default">Item 5</li> |
---|
41 | </ul> |
---|
42 | |
---|
43 | <ul id="sortable2" class='dropfalse'> |
---|
44 | <li class="ui-state-highlight">Cannot be dropped..</li> |
---|
45 | <li class="ui-state-highlight">..on an empty list</li> |
---|
46 | <li class="ui-state-highlight">Item 3</li> |
---|
47 | <li class="ui-state-highlight">Item 4</li> |
---|
48 | <li class="ui-state-highlight">Item 5</li> |
---|
49 | </ul> |
---|
50 | |
---|
51 | <ul id="sortable3" class='droptrue'> |
---|
52 | </ul> |
---|
53 | |
---|
54 | <br clear="both" /> |
---|
55 | |
---|
56 | </div><!-- End demo --> |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | <div class="demo-description"> |
---|
61 | <p> |
---|
62 | Prevent all items in a list from being dropped into a separate, empty list |
---|
63 | using the <code>dropOnEmpty</code> option set to <code>false</code>. By default, |
---|
64 | sortable items can be dropped on empty lists. |
---|
65 | </p> |
---|
66 | </div><!-- End demo-description --> |
---|
67 | |
---|
68 | </body> |
---|
69 | </html> |
---|