0

REPL

I am trying to create sections and rows with SortableJS in svelte. I want to be able to reorder sections, reorder rows within sections, and drag rows to new sections. I cannot figure out how to set the new order of the nested items in the section.

I have provided a REPL above. Moving the sections works and you can see that the underlying data's order changes. But with the rows I get an error. I don't know how to access the items within the section on sortRow

Here is my data structure.

    let stages =[
    {
        id: 1,
        section: "SECTION",
    items: [
        { id: 1 },
        { id: 2 },
        { id: 3 },
    ]
    },
    {
        id: 11,
        section: "SECTION2",
    items: [
        { id: 4 },
        { id: 5 },
        { id: 6 },
    ]
    }
]

2
  • I would use a different library that already integrates with Svelte, e.g. svelte-dnd-action. Commented Jan 2, 2024 at 16:35
  • @brunnerh I already tried that library.It doesn't handle nested lists with async data very well. I went down a whole rabbit hole with that library. Commented Jan 2, 2024 at 17:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.