Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bind to on scroll event of a DataTable

I need to bind to the on scroll event of a DataTable which is set to scroll vertically.

Its obvious that a simple event binding does not work.

$('table tbody').on('scroll', function() {
    alert('');
});

I have created a demo here.

Does any one know an API method or work around that can do this?

like image 763
Starx Avatar asked Jan 19 '13 20:01

Starx


1 Answers

It's not the table that's overflowing it's the parent div

$('.dataTables_scrollBody').on('scroll', function() {
    alert('');
});

Demo: http://jsfiddle.net/SQ5RL/1/

Furthermore, I have never used this plugin So I don't know it's behavior. If the code above happens to not work, try the one below just in case.

$('table tbody').parent().on('scroll', function() {
    alert('');
});

BTW, This is tested to work too.

like image 82
Yusaf Khaliq Avatar answered Oct 19 '22 23:10

Yusaf Khaliq