Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not allow parts of sortable jquery list to move?

I made a sortable list:

<ul>
   <li class="line"><a href="#" class="food">milk</a></li>
   <li class="line"><a href="#" class="food">eggs</a></li>
   <li class="line"><a href="#" class="food">cheese</a></li>
</ul>

However, I want to make everything with class food not draggable. Since they are links, sometimes when people click them, they accidently reorder the list. Does anyone know how to make just the "food" class items not "draggable"?

like image 784
sanpell Avatar asked Mar 08 '10 00:03

sanpell


1 Answers

Presuming your sortable selector is .line :

$('.line').sortable({ cancel: 'a.food' });

See: The cancel option in the jQuery UI documentation for details.

like image 69
ghoppe Avatar answered Sep 18 '22 14:09

ghoppe