How do you perform a reset on a JQuery Sortable

前端 未结 4 1387
我在风中等你
我在风中等你 2021-02-05 22:23

I\'m using JQuery Sortable. I\'d like to know if it\'s possible to, after a number of resortings, restore the sortable control back to its original state similar to a form reset

4条回答
  •  [愿得一人]
    2021-02-05 22:41

    Store a reference to the original element order then use that to re-order them.

    var sortableElements = $("#sortable div");
    $("#sortable").sortable();
    

    Now when you want to restore the original sort order, simply append the divs to the #sortable element.

    $("#sortable").append(sortableElements);
    

提交回复
热议问题