简体   繁体   中英

how can i sort elements on drop using JQuery UI?

I have few 'li' elements. I can drag and drop elements...but,my requirement is i need to sort element after drop(element has to move to destination after mouse release). Please help me... Here is the code i'm using,

$( ".sortable" ).sortable({
    revert: true,
    start : function(e){
        console.log(e);
    }
});
$( "li selector" ).draggable({
    connectToSortable: ".sortable",
    start : function(e){
        console.log(e);
    }
});

Is there not a onDrop event, or something similar you can listen for, to then run your sorting function?

If not, you could run a function that binds to the jQuery event .mouseup() , which then fires your sorting function.

https://api.jquery.com/mouseup/

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