jQuery Sortable lock item

▼魔方 西西 提交于 2019-12-13 17:26:06

问题


Is it possible to lock an item in a Sortable list once it's been dropped?

Basically, I have a sortable list [OBJECT] that the user is supposed to place the objects into steps. The steps are static/not moveable. Like this:

[Step 1] [OBJECT 1]

[Step 2] [OBJECT 2]

[Step 3] [OBJECT 3]

[Step 4] [OBJECT 4]

So lets say I drag object 1 to step 3:

[Step 1] [OBJECT 2]

[Step 2] [OBJECT 3]

[Step 3] [OBJECT 1]

[Step 4] [OBJECT 4]

Now any object that's dragged SHOULD NOT change the position of [OBJECT 1] because it needs to stay at step 3.

Is it possible to lock it?


回答1:


May be 'cancel' option can help ypu.

$( ".selector" ).sortable( "option", "cancel", "a,button" );

Check this link




回答2:


The best way for me to achieve this was to use drag & drop. I explain more about what I did here: jQuery Drag & drop- reorder



来源:https://stackoverflow.com/questions/15976651/jquery-sortable-lock-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!