Ticket #2729: itemQuery.patch
| File itemQuery.patch, 1.9 kB (added by rfb, 9 months ago) |
|---|
-
ui/ui.sortable.js
-
ui/demos/ui.sortable.html
91 91 </ul> 92 92 </div> 93 93 94 <h2>5. Nested lists limited to 1 level deep</h2> 95 <div class="playground"> 96 <ul id="example5" style="cursor: hand; cursor: pointer;"> 97 <li>Drag us</li> 98 <li>around</li> 99 <li>and change 100 <ul> 101 <li>Lorem</li> 102 <li>Ipsum</li> 103 </ul> 104 </li> 105 <li>our</li> 106 <li>positions 107 <ul> 108 <li>Something else</li> 109 <li>Foo bar</li> 110 </ul> 111 </li> 112 </ul> 113 </div> 114 94 115 <script type="text/javascript"> 95 116 if(!window.console) { 96 117 window.console = { … … 110 131 $("#example3").sortable({ items: "li", revert: true, tree: true }); 111 132 $("#example4").sortable({ placeholder: "hover", revert: true }); 112 133 134 $("#example5").sortable({ 135 items: "li", revert: true, tree: true, 136 itemQuery: function() { 137 if (this.currentItem) { 138 139 // if list item has a list 140 if ($('ul', this.currentItem).size()) { 141 142 // return only list items from the root list 143 return [$('> li', this.element)]; 144 } 145 } 146 return [$(this.options.items, this.element)]; 147 } 148 }); 149 150 113 151 }); 114 152 </script> 115 153 </body>
