CodingNic

Drag and Drop

Save the New Order

Drag and Drop 6 min read

Save the New Order

Your persistence functions from Module 5 should already save the tasks array. Make sure the drag-and-drop handler calls that same save function immediately after changing the order.

For example, if your save function is named saveTasks(), finish the drop handler with:

javascript
tasks.splice(toIndex, 0, movedTask);

saveTasks();
renderTasks();

Do not create a separate storage value just for the order. The task array already contains the order the app needs.

Checkpoint

Reorder several tasks, refresh the page, and confirm that the new order is restored.