Capture scroll event on div

后端 未结 3 1257
耶瑟儿~
耶瑟儿~ 2021-01-19 11:55

I\'m trying to capture the scroll event within a Backbone.Marionette.CompositeView, but without success.

As an exercise, I\'m rewriting http://www.atinux.fr/backbone

3条回答
  •  失恋的感觉
    2021-01-19 12:45

    This code works for me:

    var View = Backbone.View.extend({
      events: { "scroll": "scroll" },
      scroll: function(){ console.log( "scrolling..." ); }
    });
    

    Check the jsFiddle

    As @JoshLeitzel said I think the issue is in the DOM element it self.

    Try to by-pass Backbone doing:

    $("#content").bind( "scroll", function(){ console.log( "scrolling from jquery directly" ); } );
    

    Also try to replace:

    el: $('#content')
    

    by

    el: '#content'
    

    I don't think this is the issue but is the new style of el definition :)

提交回复
热议问题