Starx
Starx

Reputation: 78991

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?

Upvotes: 5

Views: 14219

Answers (1)

Yusaf Khaliq
Yusaf Khaliq

Reputation: 3393

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.

Upvotes: 10

Related Questions