-
-
Couldn't load subscription status.
- Fork 1.5k
Open
Description
Hello. I've got 5 items (i can dynamically ad new items) and i put a remove button inside of them. I want to remove item which clicked remove button inside of it. But always last item is being removed when i click a remove button.
here is my code.
<button @click="addItem">Add an item</button>
<grid-layout :layout="layout"
:col-num="12"
:row-height="30"
:is-draggable="draggable"
:is-resizable="resizable"
:vertical-compact="true"
:use-css-transforms="true"
>
<grid-item v-for="item in layout"
:x="item.x"
:y="item.y"
:w="item.w"
:h="item.h"
:i="item.i"
drag-allow-from=".window-header"
drag-ignore-from=".no-drag"
>
<div class="window">
<div class="window-header">Harita</div>
{{item.i}}
<button @click="removeItem">remove</button>
</div>
</grid-item>
</grid-layout>
this is code
`addItem: function() {
var self = this;
//console.log("### LENGTH: " + this.layout.length);
var item = {"x":0,"y":0,"w":2,"h":2,"i":this.index+"", whatever: "bbb"};
this.index++;
this.layout.push(item);
},
removeItem: function(item) {
console.log(item);
//console.log("### REMOVE " + item.i);
this.layout.splice(this.layout.indexOf(item), 1);
},
`
dsalaj and le-vlad
Metadata
Metadata
Assignees
Labels
No labels