jbaysolutions / vue-grid-layout

A draggable and resizable grid layout, for Vue.js.
https://jbaysolutions.github.io/vue-grid-layout/
MIT License
7.08k stars 1.49k forks source link

Add extra parameters to moved and resized events #309

Open scryptoking opened 5 years ago

scryptoking commented 5 years ago

I would like to know if it is already possible to pass extra parameters in (for example) the @moved event?

Following the documentation, I've used the @moved event as follow:

movedEvent: function(i, newX, newY){
    const info = i + "|" + newX + "|" + newY;
    alert(info);
}

What I would like is to pass an extra parameter like so:

@moved="movedEvent(myExtraParam)"

And then something like:

movedEvent: function(i, newX, newY, myExtraParam){
    const info = i + "|" + newX + "|" + newY + "|" + myExtraParam;
    alert(info);
}

But this obviously doesn't work. The reason I would like this, is that since my vue-grid-layout is being populated from a backend API, I would like to have the opportunity to pass a id field form my API to the grid-item events (in this case the @moved event).

mattgreenfield commented 5 years ago

Would this work?

@moved="(i, newX, newY) => movedEvent(i, newX, newY, myExtraParam)"
scryptoking commented 5 years ago

Will give this a try! Thanks for the reply!