'Scroll' event does not fire in CompositeView

I saw the Capture scroll event on div event , but the solution didn't necessarily work for me.

I have a JSFiddle that displays a collection through a CompositeView, but cannot trigger a scroll event (creating infinite scroll): http://jsfiddle.net/franklovecchio/FkNwG/300/ .

How can I run scroll correctly?

+6
source share
1 answer

The first scroll event only works for an overflow item: scroll / auto. In your case, this is # region-content, not #container.

But fixing a selector for events will not work, because Backbone uses Jquery.delegate () to attach its events. But the delegate cannot trigger scroll events.

I am afraid that you will have to attach the event manually after rendering the dom with

 $("#region-content").scroll () -> console.log "ok" 

You can use live () to attach events.

Alternatively, you can scroll #content and scroll it. This will work since Backbone will not use the delegate, but it will bind the event directly to the #content node.

+11
source

Source: https://habr.com/ru/post/924593/


All Articles