From b6bfc690b46aeb16191763aa874e7b8905f17a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Hern=C3=A1n=20Garc=C3=ADa?= Date: Thu, 29 Oct 2015 12:51:33 -0300 Subject: [PATCH] send parent node and modified node on tree change --- dist/react-ui-tree.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dist/react-ui-tree.js b/dist/react-ui-tree.js index a13feac2..cca82cde 100644 --- a/dist/react-ui-tree.js +++ b/dist/react-ui-tree.js @@ -201,6 +201,9 @@ module.exports = React.createClass({ }, dragEnd: function dragEnd() { + var index = this.state.tree.getIndex(this.state.dragging.id); + var parent = this.state.tree.get(index.parent); + this.setState({ dragging: { id: null, @@ -211,14 +214,14 @@ module.exports = React.createClass({ } }); - this.change(this.state.tree); + this.change(this.state.tree, parent, index.node); window.removeEventListener('mousemove', this.drag); window.removeEventListener('mouseup', this.dragEnd); }, - change: function change(tree) { + change(tree, parent, node) { this._updated = true; - if (this.props.onChange) this.props.onChange(tree.obj); + if(this.props.onChange) this.props.onChange(tree.obj, parent, node); }, toggleCollapse: function toggleCollapse(nodeId) { @@ -232,6 +235,6 @@ module.exports = React.createClass({ tree: tree }); - this.change(tree); + this.change(tree, null, null); } -}); \ No newline at end of file +});