| 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 - Include / exclude items</title> |
| 7 | <link rel="stylesheet" href="../../themes/base/all.css"> |
| 8 | <link rel="stylesheet" href="../demos.css"> |
| 9 | <style> |
| 10 | #sortable1, #sortable2 { list-style-type: none; margin: 0; padding: 0; zoom: 1; } |
| 11 | #sortable1 li, #sortable2 li { margin: 0 5px 5px 5px; padding: 3px; width: 90%; } |
| 12 | </style> |
| 13 | <script src="../../external/requirejs/require.js"></script> |
| 14 | <script src="../bootstrap.js" data-modules="disable-selection"> |
| 15 | $( "#sortable1" ).sortable({ |
| 16 | items: "li:not(.ui-state-disabled)" |
| 17 | }); |
| 18 | |
| 19 | $( "#sortable2" ).sortable({ |
| 20 | cancel: ".ui-state-disabled" |
| 21 | }); |
| 22 | |
| 23 | $( "#sortable1 li, #sortable2 li" ).disableSelection(); |
| 24 | </script> |
| 25 | </head> |
| 26 | <body> |
| 27 | |
| 28 | <h3 class="docs">Specify which items are sortable:</h3> |
| 29 | |
| 30 | <ul id="sortable1"> |
| 31 | <li class="ui-state-default">Item 1</li> |
| 32 | <li class="ui-state-default ui-state-disabled">(I'm not sortable or a drop target)</li> |
| 33 | <li class="ui-state-default ui-state-disabled">(I'm not sortable or a drop target)</li> |
| 34 | <li class="ui-state-default">Item 4</li> |
| 35 | </ul> |
| 36 | |
| 37 | <h3 class="docs">Cancel sorting (but keep as drop targets):</h3> |
| 38 | |
| 39 | <ul id="sortable2"> |
| 40 | <li class="ui-state-default">Item 1</li> |
| 41 | <li class="ui-state-default ui-state-disabled">(I'm not sortable)</li> |
| 42 | <li class="ui-state-default ui-state-disabled">(I'm not sortable)</li> |
| 43 | <li class="ui-state-default">Item 4</li> |
| 44 | </ul> |
| 45 | |
| 46 | <div class="demo-description"> |
| 47 | <p> |
| 48 | Specify which items are eligible to sort by passing a jQuery selector into |
| 49 | the <code>items</code> option. Items excluded from this option are not |
| 50 | sortable, nor are they valid targets for sortable items. |
| 51 | </p> |
| 52 | <p> |
| 53 | To only prevent sorting on certain items, pass a jQuery selector into the |
| 54 | <code>cancel</code> option. Cancelled items remain valid sort targets for |
| 55 | others. |
| 56 | </p> |
| 57 | </div> |
| 58 | </body> |
| 59 | </html> |