Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The jQuery UI <a href="http://jqueryui.com/demos/sortable/" rel="noreferrer">sortable plugin</a> provides drag-and-drop reordering. A save button can extract the IDs of each item to create a comma-delimited string of those IDs, added to a hidden textbox. The textbox is returned to the server using an async postback.</p> <p>This <a href="http://jsfiddle.net/pmw57/tzYbU/205/" rel="noreferrer">fiddle example</a> reorders table elements, but does not save them to a database.</p> <p>The sortable plugin takes one line of code to turn any list into a sortable list. If you care to use them, it also provides CSS and images to provide a visual impact to sortable list (see the example that I linked to). Developers, however, must provide code to retrieve items in their new order. I embed unique IDs of each item in the list as an HTML attribute and then retrieve those IDs via jQuery.</p> <p>For example:</p> <pre><code>// ----- code executed when the document loads $(function() { wireReorderList(); }); function wireReorderList() { $("#reorderExampleItems").sortable(); $("#reorderExampleItems").disableSelection(); } function saveOrderClick() { // ----- Retrieve the li items inside our sortable list var items = $("#reorderExampleItems li"); var linkIDs = [items.size()]; var index = 0; // ----- Iterate through each li, extracting the ID embedded as an attribute items.each( function(intIndex) { linkIDs[index] = $(this).attr("ExampleItemID"); index++; }); $get("&lt;%=txtExampleItemsOrder.ClientID %&gt;").value = linkIDs.join(","); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload