Giter VIP home page Giter VIP logo

Comments (3)

wyuenho avatar wyuenho commented on August 17, 2024

I'm not sure what you mean. fullCollection is never used to perform a fetch and reset doesn't trigger a call to parse. Can you provide a failing example?

from backbone-pageable.

ileto avatar ileto commented on August 17, 2024

I debugged very deep to find that,, so it's pretty hard to provide an example. Kind of remember:
###collectionEventHandler
if (event == "reset" || collection == fullCol) {
if (!(state.totalRecords = fullCol.models.length)) {
state.totalRecords = null;
state.totalPages = null;
state.lastPage = state.currentPage = state.firstPage;
}
pageCol.state = pageCol._checkState(state);
if (collection == pageCol) fullCol.trigger(event, fullCol, options);
resetQuickly(pageCol, fullCol.models.slice(pageStart, pageEnd),
options);
}

after the fullCol.trigger 'reset' -> pageCol got resetQuickly with the sliced models.

function resetQuickly () {
collection.reset.apply(collection, resetArgs);

pageCol.reset applied....and looks like the Backbone prototype reset got executed which will do the parse again.

MY SOURCE

User = Bac.Model.extend
    initialize: ->

Users = Bac.PageableCollection.extend
    model: User
    url: 'api/v1/relationships/list'
    mode: 'client'

    setType: (type)->
        this.queryParams.type = type
        this.queryParams.cursor = 0

    parseRecords: (resp)->
        # hot fix for pagable potential bug: pageColl parseRecords again with results from fullColl parseRecords
        if resp.users then resp.users else resp

SERVER RESP

{
total_number: 120,
users: [{},{},{}....]
}

HAHA, I just meet your plugin hours ago, so dont laugh me at the queryParams.type or cursor thing.
BTW, if any way to add extra queryParams more easily, if i don't want to change the build queryParams?

from backbone-pageable.

wyuenho avatar wyuenho commented on August 17, 2024

parse is only called if options.parse is truthy when you call reset. It's not normally called. The canonical way to add new queryParams parameters is to either provide it during override, initialization, or supply them to fetch. There are many ways to do it.

from backbone-pageable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.