1 | <!doctype html>
|
---|
2 | <html lang="en">
|
---|
3 | <head>
|
---|
4 | <title>Droppable Visual Test - Droppable ticket 4088</title>
|
---|
5 | <link type="text/css" href="../../../themes/base/ui.all.css" rel="stylesheet" />
|
---|
6 | <script type="text/javascript" src="../../../jquery-1.4.1.js"></script>
|
---|
7 | <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
|
---|
8 | <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script>
|
---|
9 | <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script>
|
---|
10 | <script type="text/javascript" src="../../../ui/jquery.ui.sortable.js"></script>
|
---|
11 | <script type="text/javascript" src="../../../ui/jquery.ui.droppable.js"></script>
|
---|
12 | <link type="text/css" href="../demos.css" rel="stylesheet" />
|
---|
13 | <style type="text/css">
|
---|
14 | #sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
|
---|
15 | #sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; }
|
---|
16 | #sortable li span { position: absolute; margin-left: -1.3em; }
|
---|
17 |
|
---|
18 | #trash { width: 58%; height: 8em; padding: 1%; margin-top: 1%; }
|
---|
19 | #trash h4 { line-height: 16px; margin: 0 0 0.4em; }
|
---|
20 | #trash h4 .ui-icon { float: left; }
|
---|
21 | </style>
|
---|
22 | <script type="text/javascript">
|
---|
23 | $(function() {
|
---|
24 | $("#sortable").sortable();
|
---|
25 | $("#trash").droppable({
|
---|
26 | accept: '#sortable > li',
|
---|
27 | activeClass: 'ui-state-highlight',
|
---|
28 | drop: function(ev, ui) {
|
---|
29 | if (ui.draggable.is('#special')) {
|
---|
30 | setTimeout(function() { ui.draggable.remove(); }, 1);
|
---|
31 | } else {
|
---|
32 | ui.draggable.remove();
|
---|
33 | ui.draggable.html('<strong>I was dropped and removed, but still here I am!</strong>');
|
---|
34 | }
|
---|
35 | }
|
---|
36 | });
|
---|
37 | });
|
---|
38 | </script>
|
---|
39 | </head>
|
---|
40 | <body>
|
---|
41 |
|
---|
42 | <h1>
|
---|
43 | Ticket <a href="http://dev.jqueryui.com/ticket/4088">#4088</a> - Unable to remove() ui.draggable (sortable item) immediately after the drop callback.
|
---|
44 | </h2>
|
---|
45 | <h2>
|
---|
46 | TEST: Drag 'Special Item' to the div labelled 'Drop here'
|
---|
47 | </h2>
|
---|
48 | <h2>
|
---|
49 | TEST: Drag a 'Normal Item' to the div labelled 'Drop here'
|
---|
50 | </h2>
|
---|
51 |
|
---|
52 | <ul id="sortable">
|
---|
53 | <li class="ui-state-default" id="special"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Special Item</li>
|
---|
54 | <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Normal Item 1</li>
|
---|
55 | <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Normal Item 2</li>
|
---|
56 | <li class="ui-state-default"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>Normal Item 3</li>
|
---|
57 | </ul>
|
---|
58 |
|
---|
59 | <div id="trash" class="ui-widget-content ui-state-default">
|
---|
60 | <h4 class="ui-widget-header"><span class="ui-icon ui-icon-trash">Trash</span> Drop here</h4>
|
---|
61 | </div>
|
---|
62 |
|
---|
63 | <h3>
|
---|
64 | ASSERT: The dropped item is removed from the original list and the following text does not appear: "<strong>I was dropped and removed, but still here I am!</strong>"
|
---|
65 | </h3>
|
---|
66 |
|
---|
67 | </body>
|
---|
68 | </html>
|
---|