I have an html table of data and each item in a row has a list_position
field which can be changed and then all of the items will be reordered to match the change on that item.
If I have a long list and I change an item from list_position
value from 1 to 1000, I would like the browser to automatically scroll down to that item after the list is re-ordered.
Currently, with this code, I am scrolled to the item's initial position, not its current position.
reorder: function (item, order, e) {
// reorder stuff ...
target = $(e.target).closest('tr');
this.scrollTo(target);
},
scrollTo: function (target) {
$('html,body').animate({
scrollTop: target.offset().top - 60
}, 1000);
return false;
}