vue-smooth-dnd
vue-smooth-dnd copied to clipboard
Cant pass parameters to :get-child-payload
I'm having an issue where I'm trying to create a nested drag-n-drop and I need to pass parameter to :get-child-payload, and I can't figure out how to do that... if it were a v-on binding, then I would call it like @get-child-payload="myFunction($event, myOtherParameter)"... but I can't find a way to pass the $event parameter...
I have a feeling there's some simple solution that I'm just missing... do you have any ideas?
Take a look at the cards example, the nested container uses :get-child-payload with a param: https://github.com/kutlugsahin/vue-smooth-dnd/blob/master/demo/src/pages/cards.vue
@mvilab I think he meant getting index + passing optional/his own parameters. I'd love to do the same as I have 2 Containers and could use same method with extra parameter that would say where it was triggered. However, I still need the index to find the item in the (separate array). This is my usecase:
items:{
visible:[],
hidden:[],
}
getChildPayload(index, initialState){
return this.items[initialState][index];
}
@get-child-payload="getChildPayload($event, 'hidden' )"
I solved it by using parametrized @drop.
@drop="changeVisibility($event, 'hidden')"
changeVisibility(dropResult, stateOfVisibility) {
// This needs to be here because the drop event is called twice,
// once on each Container but removedIndex is present only in event from original container
if (dropResult.removedIndex !== null) {
const target = this.columnsToRender[stateOfVisibility][
dropResult.removedIndex - 1
];
// Rest of function ...
}
}
What about @get-child-payload="(event) => getChildPayload(event, data)" ?