Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse response before checking length #16

Closed
wants to merge 1 commit into from

Conversation

david-crespo
Copy link

If the fetch response is not a list but rather a list wrapped in an object, like

{
   data: [ blah, blah, blah ]
}

then it needs to be parsed before calling .length on it to decide whether there are more pages to load. This is exactly what Backbone's parse function is used for. The default implementation of parse is to just pass the response through, so there's no need to check if it's there before calling it.

I don't think what's sent to success and error should be changed because people probably already depend on it working a certain way. It's less likely that anyone depends on fetchSuccess's broken behavior in strict: false mode.

This fixes #7.

@joshbedo
Copy link

@david-crespo Hmm this doesn't seem to fix the issue for me, InfiniScroll still isn't invoking the success callback :(

@david-crespo david-crespo reopened this Nov 2, 2015
@MrLeebo
Copy link

MrLeebo commented Jun 16, 2016

This works. I have a collection with the same object wrapping and a parse function like
parse: function(res) { return res.data; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fetchSuccess receives response that has not been parsed
3 participants