npm.io
0.1.0-alpha.5 • Published 9 years ago

react-jquery-sortable

Licence
MIT
Version
0.1.0-alpha.5
Deps
0
Vulns
0
Weekly
0

react-jquery-sortable

Demo

Usage

  1. Include jQuery and jQuery UI globally (this is required because of a jQuery UI limitation)
  2. Configure webpack to support import ' (see externals in webpack.config.common.js)
  3. Create the Sortable (see Example.jsx).

Code Example

import Sortable from 'react-jquery-sortable';
import Widget from './Widget';

function Example({ onChange, widgets, ...props }) {
  // - Sortable options are passed as props
  // - When an item is dropped, onChange is called with a list of ids that represents the new order
  // - Each child must have an id. The id is used to identify the order of the children.

  return (
    <Sortable
      forcePlaceholderSize
      handle=".handle"
      onChange={order => onChange(order)}
      placeholder="placeholder"
      {...props}
    >
      {widgets.map(widget => (
        <Widget
          handleClassName=".handle"
          id={widget.get('id')}
          key={widget.get('id')}
          widget={widget}
        />
      ))}
    </Sortable>
  );
}

Setup

yarn
yarn start
# Visit http://localhost:8080
from 'jquery'
(see __INLINE_CODE_1__ in __INLINE_CODE_2__)
  • Create the __INLINE_CODE_3__ (see __INLINE_CODE_4__).
  • Code Example

    import Sortable from 'react-jquery-sortable';
    import Widget from './Widget';
    
    function Example({ onChange, widgets, ...props }) {
      // - Sortable options are passed as props
      // - When an item is dropped, onChange is called with a list of ids that represents the new order
      // - Each child must have an id. The id is used to identify the order of the children.
    
      return (
        <Sortable
          forcePlaceholderSize
          handle=".handle"
          onChange={order => onChange(order)}
          placeholder="placeholder"
          {...props}
        >
          {widgets.map(widget => (
            <Widget
              handleClassName=".handle"
              id={widget.get('id')}
              key={widget.get('id')}
              widget={widget}
            />
          ))}
        </Sortable>
      );
    }

    Setup

    yarn
    yarn start
    # Visit http://localhost:8080

    Keywords