0

I am having an array of objects like this. I need to send an API request to the database to change their display order. How can I pass order_position into the body of an API request? I intend to send an API request after clicking the confirm button. Should I send an API request every time the up and down arrows are pressed? Please help me, this problem is really hard for me

getFolders() {
    let data: any[] = [
      {
        id: 100,
        name: '店舗',
        order_position: 1
      },
      {
        id: 101,
        name: '東日本統括部',
        order_position: 2
      },
      {
        id: 102,
        name: '東日本統',
        order_position: 3
      }
    ]
    this.list_folders = data
  }

enter image description here

1 Answer 1

1

if you would like to use vue-draggable, probably you can try this way

  1. use vue-draggable to rearrange element's order
  2. whenever you drag an item it will trigger an event 'change'(@change)
  3. there you can rearrange the order_position property with the index
  4. send the whole array to backend and update with id or ( truncate and reinsert) hope this may help you
Sign up to request clarification or add additional context in comments.

Comments

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.