A jQuery binding for SortableJS
npm install jquery-sortablejs
npm i -D jquery-sortablejs
`
Import into project:
`javascript
import 'jquery-sortablejs';
`
$3
`HTML
`
Usage
$3
`javascript
// Without options:
$('#my-list').sortable();
// With options:
$('#my-list').sortable({
// SortableJS options go here
// See: (https://github.com/SortableJS/Sortable#options)
handle: '.handle',
invertSwap: true,
// . . .
})
`
$3
`javascript
$('#my-list').sortable();
var mySortableList = $('#my-list').sortable('widget');
`
$3
Call .sortable() with the first argument as the option name and the second as the option value
`javascript
// Get an option
var isDisabled = $('#my-list').sortable('disabled');
// Set an option
$('#my-list').sortable('disabled', !isDisabled);
`
$3
Pass 'destroy' argument into .sortable()
`javascript
// Destroy Sortable
$('#my-list').sortable('destroy');
`
$3
Pass the name of the function as string into .sortable(), followed by any arguments
`javascript
// Sortable toArray
var order = $('#my-list').sortable('toArray');
``