diff --git a/README.md b/README.md index eea564e..9a328e8 100644 --- a/README.md +++ b/README.md @@ -306,6 +306,10 @@ sortable.sort(order.reverse()); // apply ``` +##### save() +Save the current sorting (see [store](#store)) + + ##### destroy() Removes the sortable functionality completely. @@ -313,6 +317,7 @@ Removes the sortable functionality completely. --- + ### Store Saving and restoring of the sort. diff --git a/Sortable.js b/Sortable.js index f70723e..30dd630 100644 --- a/Sortable.js +++ b/Sortable.js @@ -638,7 +638,7 @@ Sortable.active = null; // Save sorting - this.options.store && this.options.store.set(this); + this.save() } }, @@ -693,7 +693,6 @@ } }, this); - order.forEach(function (id) { if (items[id]) { rootEl.removeChild(items[id]); @@ -703,6 +702,15 @@ }, + /** + * Save the current sorting + */ + save: function () { + var store = this.options.store; + store && store.set(this); + }, + + /** * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. * @param {HTMLElement} el