绑定到 DataTable 的滚动事件 [英] Bind to on scroll event of a DataTable

查看:22
本文介绍了绑定到 DataTable 的滚动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要绑定到设置为垂直滚动的 DataTable 的 on scroll 事件.

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('');
});

我在这里创建了一个演示.

是否有人知道可以执行此操作的 API 方法或解决方法?

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

推荐答案

溢出的不是表而是父div

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

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

演示: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.

这篇关于绑定到 DataTable 的滚动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆