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.9.1.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 |
|
34 |
<ul id="sortable1" class='droptrue'> |
35 |
<li class="ui-state-default">Can be dropped..</li> |
36 |
<li class="ui-state-default">..on an empty list</li> |
37 |
<li class="ui-state-default">Item 3</li> |
38 |
<li class="ui-state-default">Item 4</li> |
39 |
<li class="ui-state-default">Item 5</li> |
40 |
</ul> |
41 |
|
42 |
<ul id="sortable2" class='dropfalse'> |
43 |
<li class="ui-state-highlight">Cannot be dropped..</li> |
44 |
<li class="ui-state-highlight">..on an empty list</li> |
45 |
<li class="ui-state-highlight">Item 3</li> |
46 |
<li class="ui-state-highlight">Item 4</li> |
47 |
<li class="ui-state-highlight">Item 5</li> |
48 |
</ul> |
49 |
|
50 |
<ul id="sortable3" class='droptrue'> |
51 |
</ul> |
52 |
|
53 |
<br style="clear:both"> |
54 |
|
55 |
<div class="demo-description"> |
56 |
<p> |
57 |
Prevent all items in a list from being dropped into a separate, empty list |
58 |
using the <code>dropOnEmpty</code> option set to <code>false</code>. By default, |
59 |
sortable items can be dropped on empty lists. |
60 |
</p> |
61 |
</div> |
62 |
</body> |
63 |
</html> |