0

페이지 매김이 필요한 백본 컬렉션을 쓰고 있습니다. requestNextPage()가 Backbone.Paginate의 함수가 아닙니다.

define([ 
    'jquery', 
    'underscore', 
    'backbone', 
    'collections/addressLists', 
    'models/object', 
    'views/shared_object_item', 

], function($, _, Backbone, AddressLists,Address,Shared_object_item){ 
    "use strict"; 

    var AppView = Backbone.View.extend({ 
    events: { 

    }, 



    initialize: function() { 

     _.bindAll(this,'render','updateData','showMoreData','showAllData');    this.collection=AddressLists; 
    this.collection.bind('reset',this.render); 
     this.collection.fetch(); 


    }, 

    el:$('div')[0], 
    render: function() { 

     var that=this; 
     $('.innerContainer').bind('scroll',function(){ 
     if($(this)[0].scrollHeight-$(this).scrollTop()==$(this).outerHeight()){ 
      that.showMoreData(); 
      } 
     }); 
     this.updateData(); 
     }, 

    updateData:function(){ 
     var that=this,collection; 
     $('.innerItem').empty(); 

     _.each(this.collection.models,function(model){ 
     $('.innerItem').append(new Shared_object_item({parent:that,collection:that.collection,model:model}).render().el); 
     }); 

    }, 
     showMoreData:function(){ 

this.collection.requestNextPage(); 

     }, 
    }); 
    return AppView; 
}); 

지금 내보기에 내가 부르고

: 그래서 내 코드는

define([ 
    'underscore', 
    'backbone', 
    'models/object', 
    'backbone_paginate' 

], function(_, Backbone, Object){ 
    "use strict"; 
    var myCollection= Backbone.Paginator.clientPager.extend({ 


    model: Object, 


     paginator_core: { 
      // the type of the request (GET by default) 
      type: 'GET', 

      // the type of reply (jsonp by default) 
      dataType: 'json', 

      // the URL (or base URL) for the service 
      url: location.protocol + '//' + location.host+'/address' 
     }, 

     paginator_ui: { 
      // the lowest page index your API allows to be accessed 
      firstPage: 1, 

      // which page should the paginator start from 
      // (also, the actual page the paginator is on) 
      currentPage: 1, 

      // how many items per page should be shown 
      perPage: 3, 

      // a default number of total pages to query in case the API or 
      // service you are using does not support providing the total 
      // number of pages for us. 
      // 10 as a default in case your service doesn't return the total 
      totalPages: 10, 

      pagesInRange: 3 
     }, 

     server_api: { 
      '$top': function() { 
       return this.totalPages * this.perPage; }, 

      }, 

     parse:function(dat){ 
     return dat.items; 
    } 


    }); 
    return new myCollection(); 
}); 

내보기는 다음과 같습니다 페치();

그리고 가져 오기가 성공하면 this.collection.requestNextPage();를 호출하려고합니다.

fetch()까지는 제대로 작동하지만 showNorePage() 함수에있는 requestNextPage 함수에 도달하면 requestNextPage()가 함수가 아니라는 오류가 발생합니다. Backbone.Paginator docsrequestNextPage(options)에서

내가 잘못 여기려고하고 wheere 잘 모릅니다

..

+1

다른 소스 코드를 공유하는 데주의하십시오. 오류가있는 곳인 것처럼 들립니다. – Lukas

답변

0

Paginator.requestPager에 편리한 방법입니다,하지만 당신은 Paginator.clientPager을 확장하고 있습니다. nextPage()을 사용해야하는 것 같습니다.