How to catch the table scroll event?

Asked

Viewed 26 times

0

I have a table with the following structure:

<table id="tab-grid">
    <thead></thead>
    <tbody></tbody>
</table>

and need to trigger Trigger javascript below when scrolling down:

$('.k-pager-refresh').trigger('click');

Whether it’s pure javascript or jquery, how can I capture the scroll event?

  • 2

    can use $('#tab-grid').on('scroll', function() { .... });

1 answer

0


$('#tab-grid').on('scroll', function() {
  $('.k-pager-refresh').trigger('click');
});

The problem with this approach is that it will always trigger the click when you scroll (change the page position).

One possible solution to this is to control where Rigger will do it. Ex, at the bottom of the page:

$(window).on('scroll', () => {
  let tamanhoPagina = document.body.scrollHeight                         
  if(Math.round(document.documentElement.scrollTop) == tamanhoPagina) {
    // continua
  }
})

Browser other questions tagged

You are not signed in. Login or sign up in order to post.