When I insert a data through ajax, I have used
$( "#example_wrap" ).load(window.location.href + " #example" );
to reload a div, but after this has done, my dragging and sorting the list is not working, so I just used
sort_table;
$('#example tbody').sortable('destroy');
$('#example tbody').unbind();
sort_table;
sorting functions are assigned to the variable sort_table
sort_table =
$( "#example tbody" ).sortable({
axis: 'y',
update: function (event, ui) {
var self = $(this)[0];
var tr = $(self).find('tr');
topnews_a = [];
var order = 1;
$(tr).each(function(){
var content_id = parseInt( $(this).attr('content_id') );
var order_id = order;
topnews_a.push({
content_id: content_id,
order_id: order_id,
});
order++;
});
var topnews_obj = JSON.stringify(topnews_a);
var data_a = {
topnews: topnews_obj
}
$.ajax({
type:"POST",
url: base_url+"topnews/do_order",
data: data_a,
beforeSend:function(){
//$('.clearClassBlock').html('<div class="alert alert-danger alert-dismissable">Select A Section.</div>');
},
complete:function(){
},
success:function(x){
alert('Order Changed Successfully');
},
error:function(x){
}
});
}
});