Browse Source

Allow a custom setState handler on the using component

Only components having a state are currently working correctly with the sortable mixing. The proposed fix is to allow custom state handling method to be passed in as config.
pull/595/head
Slavic Dragovtev 9 years ago
parent
commit
44e1ab8f00
  1. 9
      react-sortable-mixin.js

9
react-sortable-mixin.js vendored

@ -81,7 +81,7 @@
componentDidMount: function () {
var options = _extend(_extend({}, _defaultOptions), this.sortableOptions || {}),
var DOMNode, options = _extend(_extend({}, _defaultOptions), this.sortableOptions || {}),
copyOptions = _extend({}, options),
emitEvent = function (/** string */type, /** Event */evt) {
@ -120,7 +120,11 @@
}
newState[_getModelName(this)] = items;
if (copyOptions["stateHandler"]) {
this[copyOptions["stateHandler"]](newState);
} else {
this.setState(newState);
}
(this !== _activeComponent) && _activeComponent.setState(remoteState);
}
@ -130,9 +134,10 @@
}.bind(this);
}, this);
DOMNode = this.getDOMNode() ? (this.refs[options.ref] || this).getDOMNode() : this.refs[options.ref] || this;
/** @namespace this.refs — http://facebook.github.io/react/docs/more-about-refs.html */
this._sortableInstance = Sortable.create((this.refs[options.ref] || this).getDOMNode(), copyOptions);
this._sortableInstance = Sortable.create(DOMNode, copyOptions);
},
componentWillReceiveProps: function (nextProps) {

Loading…
Cancel
Save