Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Update items or remove #4298

Open
nasir-awan opened this issue May 27, 2019 · 0 comments
Open

Update items or remove #4298

nasir-awan opened this issue May 27, 2019 · 0 comments

Comments

@nasir-awan
Copy link

nasir-awan commented May 27, 2019

I am using visjs and react-visjs-timeline in our reactjs application. I want to catch onMove, OnRemove etc event and call any other method within component to update items in state or redux store. When I try to do it, it throws an error Uncaught TypeError: .... is not a function

It seems like in onMove, onRemove ... other methods could not be reached within a component.

The items are updated in the timeline, but state items and group are not being updated. Looks like only one way data-binding .... If I change any item in the state, then it updates timeline.

Packages used
react-visjs-timeline: 1.5.0
vis version: 4.12.0

Code sample
`class TimelineExample extends React.Component {

onMoveItem = ()=>{
console.log('Im moving');
}

onRemoveItem = () => {
console.log('Im removing');
}

render() {
const options = {
height: 350, // px
editable: {
add: true,
remove: true,
updateTime: true
},
itemsAlwaysDraggable: true,
onMove: function (item, callback) {
onMoveItem(); // Error here
},
onRemove: function (item, callback) {
onRemoveItem(); // Error here
},
};

let items = new vis.DataSet([{
  id: 1,
  content: 'First event',
  start: '2014-08-01'
}, {
  id: 2,
  content: 'Second',
  start: '2014-08-08'
}]);

<Timeline
  options = {this.options}
  items={this.items}
/>   

}
}`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant