Mootools Sortable-- move up/down

241 Views Asked by At

I'm working with Mootools sortables (v1.4).

I've got a list of items and the sorting works great via drag/drop actions. However, I'd like to also add an "up/down" arrow to each list item so that users could also just click an item up or down one "slot" if they preferred.

I didn't see anything in the docs about a method to accomplish this. Is there a way to do this?

Thanks!

1

There are 1 best solutions below

0
On BEST ANSWER

why don't you just move the list item in the DOM on click of these arrows ? It won't mess with the sortable ;)

An example piece of code could look like this :

function moveUp (liID) {
    var prev = $(liID).getPrevious();
    if(prev)
        $(liID).inject(prev,"before");
}
function moveDown (liID) {
    var next = $(liID).getNext();
    if(next)
        $(liID).inject(next,"after");
}