Skip to content

Instantly share code, notes, and snippets.

@gabrielhpugliese
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielhpugliese/6c5b52fd658b991ae5a2 to your computer and use it in GitHub Desktop.
Save gabrielhpugliese/6c5b52fd658b991ae5a2 to your computer and use it in GitHub Desktop.
define(function (require) {
'use strict';
var React = require('react');
var _ = require('underscore');
var DragDropMixin = require('react-dnd').DragDropMixin;
var ItemTypes = require('components/ItemTypes');
var dragSource = {
beginDrag: function (component) {
debugger;
return {
item: {
id: component.props.id
}
};
}
};
var dropTarget = {
over: function (component, id) {
debugger;
}
};
var DraggableDiv = React.createClass({
mixins: [DragDropMixin],
statics: {
configureDragDrop: function (register) {
register(ItemTypes.INPUT, {
dragSource: dragSource,
dropTarget: dropTarget
});
}
},
render: function () {
return <div
{...this.dragSourceFor(ItemTypes.INPUT)}
{...this.dropTargetFor(ItemTypes.INPUT)}
>
<h1>teste</h1>
</div>;
}
});
var DraggableForm = React.createClass({
render: function () {
return <div>{_.map([1,2,3,4,5], function (index) {
return <DraggableDiv id="div-{index}" />;
})}</div>;
}
});
return DraggableForm;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment