April 24, 2012
Jquery sortable, how to disable drag and drop
Question by Meg Lepett
<ul id="box">
<li id="1">1</li>
<li id="2">2</li>
</ul>
$("#box").sortable({ update: function() {
var order = $("#box").sortable("serialize");
alert(order);
}
});
I would like to control the order by pressing buttons, and disable the drag and drop.
Everything works great but i could not figure out how to disable the drag and drop but still remain this list sortable?
Edit –
Ok now i start to understand this. I do not need to use sortable at all.
How to get the same result in order variable without using sortable?
Answer by Starx
On that case, you don’t need sortable at all. Just use .append()
and .prepend()
to shift the position.
$("#link-left").click(function() {
$("#placetoshift").append($("#thesortablediv"));
});