最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - 'scroll' event not firing in CompositeView - Stack Overflow

programmeradmin3浏览0评论

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

I have a JSFiddle that renders a Collection via a CompositeView, but can not get the scroll event to fire (building an infinite scroll): /.

How can I get scroll to fire correctly?

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

I have a JSFiddle that renders a Collection via a CompositeView, but can not get the scroll event to fire (building an infinite scroll): http://jsfiddle/franklovecchio/FkNwG/300/.

How can I get scroll to fire correctly?

Share Improve this question edited May 23, 2017 at 10:29 CommunityBot 11 silver badge asked Sep 4, 2012 at 20:51 user375566user375566
Add a ment  | 

1 Answer 1

Reset to default 11 +50

First scroll event only works for element that have overflow: scroll/auto. In your case it is the #region-content and not the #container.

But fixing the selector for events will not work, because Backbone uses jquery .delegate() to attach it's events. But delegate fails to trigger for scroll events.

I am afraid 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 the events.

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

发布评论

评论列表(0)

  1. 暂无评论