DG DC; $("window") doesn't actually work in the binding scenario

This commit is contained in:
danielgrippi 2012-01-19 17:16:58 -08:00
parent 750e26e8fb
commit 356494b78b
2 changed files with 3 additions and 4 deletions

View file

@ -31,7 +31,7 @@ app.views.Stream = Backbone.View.extend({
}, },
unbindInfScroll : function() { unbindInfScroll : function() {
$("window").unbind("scroll"); $(window).unbind("scroll");
}, },
render : function(evt) { render : function(evt) {
@ -63,11 +63,11 @@ app.views.Stream = Backbone.View.extend({
setupInfiniteScroll : function() { setupInfiniteScroll : function() {
var throttledScroll = _.throttle($.proxy(this.infScroll, this), 200); var throttledScroll = _.throttle($.proxy(this.infScroll, this), 200);
$("window").scroll(throttledScroll); $(window).scroll(throttledScroll);
}, },
infScroll : function() { infScroll : function() {
var $window = $("window"); var $window = $(window);
var distFromTop = $window.height() + $window.scrollTop(); var distFromTop = $window.height() + $window.scrollTop();
var distFromBottom = $(document).height() - distFromTop; var distFromBottom = $(document).height() - distFromTop;
var bufferPx = 500; var bufferPx = 500;

View file

@ -65,7 +65,6 @@ describe("app.views.Stream", function(){
it("unbinds scroll", function() { it("unbinds scroll", function() {
spyOn($.fn, "unbind") spyOn($.fn, "unbind")
this.view.unbindInfScroll() this.view.unbindInfScroll()
expect($.fn.unbind.mostRecentCall.object.selector).toBe("window")
expect($.fn.unbind).toHaveBeenCalledWith("scroll") expect($.fn.unbind).toHaveBeenCalledWith("scroll")
}) })
}) })