How to exclude an element from being dragged in sortable list? How to exclude an element from being dragged in sortable list? jquery jquery

How to exclude an element from being dragged in sortable list?


You need to use cancel.

See working example here.

Js:

$(function() {    $('.sortable').sortable();    $('.sortable').disableSelection();    $('.sortable').sortable({ cancel: '.note' });});​

As @Zephyr points out, this let's you re-arrange the position by dragging the siblings, if you want to avoid that, use owise1 approach:

$('.sortable').sortable({    items : ':not(.note)'});


You could use sortable's "items" option:

$( ".sortable" ).sortable({    items : 'li'});

example

or...

$( ".sortable" ).sortable({    items : ':not(.note)'});

example


You can explicitly exclude items with:

$( ".sortable" ).sortable({     cancel: ".disable-sorting"});