绑定到DataTable的滚动事件 [英] Bind to on scroll event of a DataTable
本文介绍了绑定到DataTable的滚动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要绑定到设置为垂直滚动的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('');
});
我已经创建了一个 demo 。
有没有人知道可以做到这一点的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,这也经过测试。
BTW, This is tested to work too.
这篇关于绑定到DataTable的滚动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文