Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I move list elements in jQuery UI Sortable without the mouse, purely in jQuery?

I want to just set up a link that allows the user to jump a given sortable list element to the top of the list. I need something like

$('.sortable li:last-child').move('.sortable li:first-child');

...where I can just cause a link to pop any list element up to the top of the list.

Never mind! I found the answer. $(id).prependTo($('#list'));

like image 240
Giles Bowkett Avatar asked Jan 21 '10 00:01

Giles Bowkett


1 Answers

Not sure if it's the best solution but this should work.

$('.sortable li:last-child').live('click', function() {
    $(this).prependTo('.sortable');
});

Kind of hard to help further without seeing more code.

like image 195
anomareh Avatar answered Oct 31 '22 19:10

anomareh