I'm having some trouble with the scroll event.
I'm trying to attach/bind the event to a specific div,
and I'm using $('body').on()
to do it, due to the fact that
the content is reloaded when sorting, so it will lose its binding.
This doesn't work, the event is not fired:
$('body').on('scroll', 'div.dxgvHSDC + div', function () {
}
This on the other hand works:
$('body').on('mousewheel DOMMouseScroll', 'div.dxgvHSDC + div', function () {
}
And this as well:
$('div.dxgvHSDC + div').on('scroll', function () {
}
What's the problem?
On modern browsers (IE>8), you can capture
scroll
event to e.gdocument
level for dynamic element. As jQuery doesn't implement capturing phase, you have to use javascriptaddEventListener()
method:You can not add delegation to the
scroll
event. This event doesn't bubble up the DOM and therefore you can not delegate it to any element. You can find more information here:You will need to create the event handler inside the event which creates your scrolling element.
Living example: http://jsfiddle.net/Um5ZT/1/