GithubHelp home page GithubHelp logo

Comments (8)

latentflip avatar latentflip commented on July 3, 2024

Hi @gpicazo,

What you're trying to do looks right to me. Would it be possible to post some examples of the data your api is returning so I can try and replicate the issue and find a fix? Maybe just paste a couple of examples of the data returned by /api/event-dates into a gist.github.com gist?

from ampersand-collection.

latentflip avatar latentflip commented on July 3, 2024

Can you also show the code for EventDate? I just created an example locally that seems to work for me, so I need to see some more of what you're doing to try and help track it down. Thanks! 😄

from ampersand-collection.

genaro-picazo avatar genaro-picazo commented on July 3, 2024

Hi @latentflip,

I have created the following gist with the requested info:
https://gist.github.com/gpicazo/964dd9cb1dc168071530

I've also included the part of the package.json that shows the versions of each & component that I am using.

from ampersand-collection.

latentflip avatar latentflip commented on July 3, 2024

Hi @gpicazo, at what point are you checking that the data is sorted, can you show me where you are doing that? I'm trying to replicate this with your code and data but it's all looking okay to me :/

from ampersand-collection.

genaro-picazo avatar genaro-picazo commented on July 3, 2024

All I am doing is rendering the collection in a view using the view's renderCollection method. I then fetch the collection data:

render: function() {
        this.renderWithTemplate();
        this.renderCollection(this.collection, EventDateItem, this.getByRole('event-dates'));
        this.fetchEventDates();
        ...
}

...

fetchEventDates: function() {
        this.collection.fetch({
            data: {
                fromDate: this.fromDate.valueOf(),
                toDate: this.toDate.valueOf()
            }
        });
    }

I've tried adding a success callback to the fetch request that manually sorts the collection on success (and even tried wrapping the call to sort in a setTimeout closure to insure the returned data was in the collection obect), but I get the same results.

the EventDateItem view is very simple and just initializes the template and binds a couple of the model properties to some elements.... nothing fancy.

from ampersand-collection.

latentflip avatar latentflip commented on July 3, 2024

Oh, so it's in the rendering that you're seeing them unsorted? That probably means it's possibly because of an old bug in ampersand-collection-view causing the view not to update correctly, and you're on outdated version of ampersand-view.

Try changing ampersand-view: "6.0.3", in your package.json to ampersand-view: "^6.0.9", (note the additional ^ and the change to 6.0.9). Then run npm update from your project directory to pull in ampersand-view 6.0.9, and try again.

from ampersand-collection.

genaro-picazo avatar genaro-picazo commented on July 3, 2024

That worked. Thank you.

I suspected it was an outdated package, I really should've followed that hunch and updated all of them :(.

from ampersand-collection.

latentflip avatar latentflip commented on July 3, 2024

No problem!

from ampersand-collection.

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.