I have been looking at
http://jqueryui.com/demos/sortable/#default
most of the day. I would imaging updating a database with the new values is what most would want. As I am using ASP.NET my idea is to use the serialize to send the new values to a page that updates the database. Here is the script:
<script type="text/javascript">
jQuery(function() {
$("#sortable").sortable();
$("#sortable").disableSelection();
});
jQuery(function() {
$("#sortable li:lt(3)").css("font-weight", "bold");
});
jQuery(function() {
$("#cmdUpdateSortOrder").click(function() {
$(".neworder").append("<br />");
$("#sortable li.ui-state-default").each(function() {
$(".neworder").append($(this).text() + "<br />");
});
var str = $("#sortable li.ui-state-default").sortable("serialize");
alert(str);
var result = $('#sortable li').sortable('toArray');
alert(result);
});
});
</script>
The 1st function is lifted from the jQueryUI example, The 2nd function highlights the top three rows, The 3rd function writes the new order to the page after a button click. Both the alerts give me:
[object Object]
I was hoping for an id and value pair, something like 0=3&1=2&2=4 etc. Also if anyone has any better ways of doing this, (ajax?) it would be much appreciated.