A sortable Marionette.CollectionView powered by jQuery UI Sortable or HTML5 Sortable.
- CollectionView with jQuery UI Sortable
- CollectionView with HTML5 Sortable
- CompositeView with jQuery UI Sortable
Load marionette-sortable.js
and other dependencies.
<script src="marionette-sortable.js"></script>
Extend your CollectionView from Marionette.SortableCollectionView
.
Note that html5sortable: true
is required when using HTML5 Sortable.
var YourCollectionView = Marionette.SortableCollectionView.extend({
...
// Optional object to be passed to the $.sortable()'s argument.
sortableOptions: {
html5sortable: true // Required when using HTML5 Sortable.
}
});
Marionette Sortable also provides Marionette.SortableBehavior
.
This enable you to make sortable any Marionette.CollectionView
s without inheriting Marionette.SortableCollectionView
.
Note that html5sortable: true
is required when using HTML5 Sortable.
var YourCollectionView = Marionette.CollectionView.extend({
...
behaviors: {
Sortable: {
behaviorClass: Marionette.SortableBehavior,
html5sortable: true // Required when using HTML5 Sortable.
}
}
});