MaxLeiter / MaxLeiter/sortablejs-vue3

How to get the new list as an array?

Open
#100 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Vue
Stars
413
Forks
27
PR merge metrics
No merged PRs in 30d

Description

I have trouble getting the new array list.
here is my code

<template>
  <div>
    <Sortable :list="elements" item-key="id" tag="div" :options="options" @change="DragableData($event)">
      <template #item="{ element, index }">
        <div :key="element.id">
          {{ index }} - {{ element.name }}
        </div>
      </template>
    </Sortable>
  </div>
</template>

<script setup>
const elements = [
  { id: "1", name: "one" },
  { id: "2", name: "two" },
  { id: "3", name: "three" },
  { id: "4", name: "four" },
];
const options = {sort: true};

function DragableData(data) {
  console.log(data)
}
</script>

data here does not have any array in it. is it possible to get new array?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the component's @change handler and inspect the event logged by DragableData(data), comparing it with the elements list. Check the library's change-event behavior and determine whether a reordered array is exposed; done means the expected new list can be obtained after dragging.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.