Lighthouse-io / react-visjs-timeline

React component for the vis.js timeline module
MIT License
210 stars 91 forks source link

Editing items #66

Open nasir-awan opened 5 years ago

nasir-awan commented 5 years ago

Overview

Handle editing items

I have integrated with reactjs app, I need to update item in state or make a call to method using onMove event but it does not allow.

Uncaught TypeError: this.handleMove is not a function

Package versions

react-visjs-timeline: 1.5.0 vis version: 4.12.0

Code Snippet

options = { onMove: function(item, callback){
//this.handleMove();
} }

image

foobarbecue commented 5 years ago

I need this too!

foobarbecue commented 5 years ago

Wait a minute. This works fine for me! I have:

  const onMoveItem = (item, callback) => {
    console.log(item)
    item.paneObj.startTime = item.start
  }
  const jsvizTlOptions = {
    showCurrentTime: false,
    onMove: onMoveItem
  }
nasir-awan commented 5 years ago

okay great - now it access state

nasir-awan commented 5 years ago

This works ...

const { updateTimelineItem } = this.props

const onMoveItem = (item, callback) => {
    console.log(item)
    updateTimelineItem(item) 
  }
  const options = {
    showCurrentTime: false,
    onMove: onMoveItem
  }