thomasdavis / backbonetutorials

As single page apps and large scale javascript applications become more prominent on the web, useful resources for those developers who are jumping the ship are crucial.
http://backbonetutorials.com
2.3k stars 1.7k forks source link

Backbone infinite scroll #114

Closed breet closed 10 years ago

breet commented 10 years ago

Hi I am trying to use your infinite scroll but it's loading the first page again and again(on scroll). Here is my collection var TaskCollection = Backbone.Collection.extend({

        model: TaskModel,

           url: 'tasks?page=' + this.page  ,
           parse: function(resp, xhr) {
             return resp.data;
            },
          page: 1,
          });

load function from my view loadResults: function () { var self = this; this.isLoading = true; console.log(this.taskCollection.page); this.taskCollection.fetch({ success: function (models) { var Len = models.length; console.log(models.models); for (var i = 0; i < Len; i++) {

                        var taskView = new TaskView({
                            model: models.models[i]
                        });

                        self.subViews.push(taskView);

                        self.$('tbody').append(taskView.render().el);  

                    }
                     that.isLoading = false;
                }
  });  

},  
console.log(this.taskCollection.page); from loadResult gives correct page number. what am I doing wrong?? Thanks in advance