开发者

jquery UI sortable: how to leave the original visible until the drop?

开发者 https://www.devze.com 2022-12-18 11:01 出处:网络
In the standard behavior demonstrated at http://jqueryui.com/demos/sortable/ when you drag an item in the list a placeholder element is displayed where the item would be dropped.

In the standard behavior demonstrated at http://jqueryui.com/demos/sortable/ when you drag an item in the list a placeholder element is displayed where the item would be dropped.

However, the original location of the item to be dropped is not indicated.

I would like to leave the original location visible until the drop, so that the visual feedba开发者_如何学编程ck is analogous to the way the original is left in place for the "semi-transparent clone" option depicted at http://jqueryui.com/demos/draggable/#visual-feedback

Is there any way I can do this with sortable?

Thanks!


So one approach that seems to work (thought it's definitely a hack) is to pass the option

start: function (e, ui) { ui.item.show();}

which unhides the automatically hidden original (ui.item).

And, more generally, one can use the start function to modify the item.


The option helper: 'clone' will leave your original item in place, while creating a new DOM element that is actually dragged around by the mouse. (Additionally, you use the option opacity: 0.7 to create the "semi-transparent" effect on the helper.)

I'm not sure if you'll need this, but if using a clone doesn't remove the item automatically from the list, you can then use the remove event to delete the item that was dragged out from the DOM entirely.

0

精彩评论

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