Skip to content
A jQuery binding for SortableJS
Branch: master
Clone or download
Latest commit faaa031 Dec 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore first version Dec 18, 2018
README.md CDN Dec 20, 2018
jquery-sortable.js first version Dec 18, 2018
package.json 1.0.1 Dec 20, 2018

README.md

jQuery SortableJS

A jQuery binding for SortableJS

Installation

Webpack/Browserify

Install package:

npm i -D jquery-sortablejs

Import into project:

import 'jquery-sortablejs';

CDN:

<script src="https://cdn.jsdelivr.net/npm/jquery-sortablejs@latest/jquery-sortable.js"></script>

Usage

Initialization

// 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,
	// . . .
})

Getting Sortable instance

$('#my-list').sortable();


var mySortableList = $('#my-list').sortable('widget');

Getting/Setting options

Call .sortable() with the first argument as the option name and the second as the option value

// Get an option
var isDisabled = $('#my-list').sortable('disabled');

// Set an option
$('#my-list').sortable('disabled', !isDisabled);

Destroying Sortable

Pass 'destroy' argument into .sortable()

// Destroy Sortable
$('#my-list').sortable('destroy');

Calling Sortable functions

Pass the name of the function as string into .sortable(), followed by any arguments

// Sortable toArray
var order = $('#my-list').sortable('toArray');

License

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.