简体   繁体   中英

jQuery sortable replace instead of append?

Hey guys was just wondering if there was anyway to replace a list item instead of appending it from a connected list, then putting the replaced item in the connected list the draged item came from? is jquery sortable capable of this any help would be greatly appriciated! Thanks

What is the effect you are trying to achieve?

I am fairly sure sortable doesn't have this capability available by its api, but do you really need sortable or do you just need a list of draggable objects that snap to a table/list? does this list need to be sortable?

Sortable has a 'sortchange' event, which fires when the order of a list has changed:

$('#mysortable').bind('sortchange', function(evt,ui){
 //perform some action once the list order has changed 
});

Perhaps this link will help: http://jqueryui.com/demos/draggable/#option-connectToSortable

You could define a list of draggable elements and add the connectToSortable options, specifying the selector for the list (that you want sortable) where you would like the resulting element to be put.

I suspect what you actually want is to define draggable and droppable objects and targets so you can move things around and have them snap into positions and react when their positions change.

If you could be more specific about your scenario and goals I could give a more specific answer ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM