Return to Snippet

Revision: 26442
at April 28, 2010 12:09 by eternicode


Initial Code
/*
<div id="rleft">
    <p>etc</p>
    <p>etc</p>
    <p>etc</p>
</div>
*/

$("#rleft").sortable({
    axis: 'y',
    items: "p",
    start: startdrag,
    stop: stopdrag,
})

function startdrag(event, ui){
    var old_position = $("#rleft p").index(ui.item)
    ui.item.data("old", old_position)
}
function stopdrag(event, ui){
    var new_position = $("#rleft p").index(ui.item)
    ui.item.data("new", new_position)
    var old_position = ui.item.data("old")
    var change = new_position - old_position
    var moved_up = change > 0
}

Initial URL

                                

Initial Description

                                

Initial Title
jQuery UI: Get sortables position before/after and change.

Initial Tags
javascript, jquery

Initial Language
JavaScript