dyan tb
dyan tb

Reputation: 79

Remove table row after post 1 item inline table in vueJS

I have inline table from database connection with vueJS. the plan is to make a duplicate of one of the rows. row was successfully duplicated with this.array.push (... ...)

but when I want to remove it in a way this ar.array.splice (index (from row), 1) the deleted ones are the top or bottom, not the row in the index that was clicked on

  1. duplicate result
  2. after click button remove row duplicate antigua country which was previously duplicated instead disappears
  3. deleted and even antartica row, while the one i removed was row antigua

code:

  public duplicate(){
    this.countries.push({ 
      name: this.multipleSelection[0].name, 
      code: this.multipleSelection[0].code, 
      currencyId: this.multipleSelection[0].currencyId,
      currencyName: this.multipleSelection[0].currencyName,
      duplicate: true
    })
  }

  public cancelDuplicate(item, index){
    this.countries.splice(index, 1)
    console.log(index)
  }

Upvotes: 0

Views: 172

Answers (1)

You can use findIndex to splice arr

this.countries.splice(this.countries.findIndex(e => e === index),1)

Upvotes: 3

Related Questions