vue-smooth-dnd icon indicating copy to clipboard operation
vue-smooth-dnd copied to clipboard

Cant pass parameters to :get-child-payload

Open rossunger opened this issue 5 years ago • 4 comments
trafficstars

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?

rossunger avatar Apr 19 '20 17:04 rossunger

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 avatar Apr 21 '20 17:04 mvilab

@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' )"

thebrownfox avatar Jul 24 '20 09:07 thebrownfox

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 ...
            }
        }

thebrownfox avatar Jul 24 '20 10:07 thebrownfox

What about @get-child-payload="(event) => getChildPayload(event, data)" ?

Cmacu avatar Sep 23 '20 03:09 Cmacu