开发者

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

开发者 https://www.devze.com 2022-12-22 17:30 出处:网络
I made a sortable list: <ul> <li class=\"line\"><a href=\"#\" class=\"food\">milk</a></li>

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 dra开发者_高级运维ggable. 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"?


Presuming your sortable selector is .line :

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号