Search code examples
jqueryasp.netrowjquery-ui-sortabledatalistitem

ajax posting of new sorted jquery datalist to get the position of newly settled rows asp.net


$(window).load(function () {
   $("table").sortable({
     items: "div",
     opacity: 0.6,
     cursor: 'move',
     update: function (event, ui) {
       var order = $('#form1').serialize();
       $.ajax({
         type: "POST",
         url: "Default7.aspx/Update",
         data: "{'NewOrder': '" + order + "'}",
         dataType: "json",
         contentType: "application/json"
       });
     }
   });
 }); 


[System.Web.Services.WebMethod]
public static void Update(string NewOrder)
{
}

how can i alert the newly sorted rows?


Solution

  • Try this:

    $(document).ready(function () {
        $("table").sortable({ items: "div", opacity: 0.6, cursor: 'move', update: function (event, ui) {
             var order = $('#form1').serialize();
             $.ajax({
                 type: "POST",
                 url: "Default7.aspx/Update",
                 data: {"NewOrder" : order },
                 dataType: "json",
                 contentType: "application/json",
                 success:function(){// add success callback function to sort row
                    // add you code to sort the table
                    // or call $('table').sortable() again
                 }
             });
           }
       });
    });