alexcode / vue2vis

A Vuejs 2 adapter for Visjs
MIT License
217 stars 59 forks source link

How to access onMove timeline event #44

Closed bjschwarz closed 5 years ago

bjschwarz commented 5 years ago

In the Vis library you can pass in callbacks within the options of the timeline. Such as onMove, onRemove, etc (vis). I can't find a way to use this in the vue scope. Is there a way to bind these or an alternate route?

Menighin commented 5 years ago

Hi @bjschwarz . These events you mentioned are configured insite the options on Vis. Therefore we can pass the event in the configuration object on vue2vis. Check this fiddle: https://jsfiddle.net/ygcj2ehb/

We could though emmit an event by default on this but I don't think thats implemented. @alexcode who implemented this may know better.

Regards,

bjschwarz commented 5 years ago

@Menighin Thanks for the response. I also tried the method you suggested. The problem I ran into is there is no access to the vue object within a callback passed to Vis. The "this" object is not within the functions scope. Any ideas how to get around this?

gg-g commented 5 years ago

Hi @Menighin @bjschwarz

Did you manage to find a solution for this?

I have a similar issue. I'm trying to call a Vue method from within a groupTemplate. Same issue - see https://jsfiddle.net/ers37v98/1/

alexcode commented 5 years ago

@bjschwarz, an arrow function will share the current scope onMove: () => alert("move: " + JSON.stringify(this.selectedId)),

https://jsfiddle.net/alexkodo/soung8h2/1/

bjschwarz commented 5 years ago

@alexcode Thanks for the jsfiddle. I think if all the item data was set on select then the onMove would be accurate for the last selected object. Looks like it should work.