Comments (10)
I'll put up a demo later today of how I have it working, but could you send a link to your example?
from infinite-scroll.
one thing to keep in mind...whenever there's an instance of infinite scroll, it needs to have it's own div.navigation
. what error comes up when you switch debug on?
from infinite-scroll.
After doing some more testing and creating a demo page for multiple instances, I found out Hans was right with the $(document).ajaxError
terminating for every instance of the plugin.
I've redone the error function to be...
function infscrError(xhr){
if (!opts.isDone && xhr == 404) {
// die if we're out of pages.
debug('Page not found. Self-destructing...');
showDoneMsg();
opts.isDone = true;
opts.currPage = 1; // if you need to go back to this instance
$(window).unbind('scroll.infscr.'+opts.infid, infscrSetup);
$(document).unbind('retrieve.infscr.'+opts.infid,kickOffAjax);
}
if (opts.isFiltered && xhr == 302) {
// die if filtered.
debug('Filtered. Going to next instance...');
opts.currPage = 1; // if you need to go back to this instance
opts.isPaused = false;
$(window).unbind('scroll.infscr.'+opts.infid, infscrSetup)
.unbind('pause.infscr.'+opts.infid)
.unbind('filter.infscr.'+opts.infid)
.unbind('error.infscr.'+opts.infid);
$(document).unbind('retrieve.infscr.'+opts.infid,kickOffAjax);
}
}
Errors will be triggered using...
$(window).trigger( "error."+opts.infid, [404] );
Here's something to think about, though. The infscr-loading
box is set under props
, so only one instance of it could exist. Should this be defined in opts
, and each instance creates its own "#infscr-loading-"+opts.infid
with a general class of infscr-loading
(for easy styling)?
My demo page should be up later today or tomorrow.
from infinite-scroll.
http://lukeshumard.com/misc/infinite-scroll-demo/
okay, here's something for now. that has multiple instances working. i'm sure there's still cleanup to do.
i've also done a commit with the error changes.
from infinite-scroll.
As an update to this it looks as though having the "pixelsFromNavToBottom" under props was causing multiple instance conflicts. I've moved this out into opts for my latest commit,. I've also modified it; my last commit (a while ago) you had to manually define an infid for each instance, now it generates a randomish ID for each instance. Could you clarify how your isFiltered part works?
from infinite-scroll.
Nice catch on the pixelsFromNavToBottom
!
The isFiltered
is basically a way to trigger the function filterNav as isDone
. How I have it on my project is...
$(window).trigger('filter.infscr');
That trigger causes infscrError to fire, and will go through the necessary code to unbind and such.
Out of curiosity, what is the benefit to having a random number for opts.infid? I think just having opts.infid set as 1 or being manually set is sufficient.
from infinite-scroll.
Ahh, isn't infscrError called when loadCallback is called and it detects a 404? On the trigger example the errorCallback is used to unbind the nav etc, is this a different way?
Yeah we could revert back to having to manually set it; I just thought it would make it easier for newer users trying to use multiple instances for the first time and it just working "out of the box" as it would save the user having to set the infid for each one. What do you think?
from infinite-scroll.
infscrError is called and detects a 404, but being filtered needs to cause several different unbindings and such. we could try to get it down to one error, but i think it's a good idea to have them separate for debugging.
i'm not opposed to having the random number as an option, but what if it would only generate a random number if you set infid to 0?
from infinite-scroll.
At the moment it only generates a random number if you don't define one, I think this might be a better way of doing it?
I agree -- keeping them separate is a better option :)
from infinite-scroll.
Since this issue seems to be resolved, I will go ahead and close it and make sure to include a demo for this in the new site.
from infinite-scroll.
Related Issues (20)
- How can I parse the next/prev links of loaded pages? HOT 1
- standby function with sticky footer HOT 1
- infinite-scroll with websockets
- tile HOT 1
- Items shown and total items under view more button HOT 3
- Fackbook hack
- Infinite scroll + JSON
- Cloudflare mirage data-cfsrc lazy load conflict
- my tumblr theme's images not loading after page 1 (Safari only) - Infinite scroll & load more issue HOT 3
- Feature - Combination with Pagination - Load and Scroll to specific Page
- Page Link Issue
- Card Columns Not Working
- Web App For Iqama status
- Infinite-scroll and Joomla
- View Transitions
- Infinite Scroll + Masonry works only sometimes, sometimes it bugs HOT 1
- prefill loads data endlessly when container has display:none HOT 2
- Deprecating the unload event HOT 2
- Rating of a topic and infinite scroll HOT 1
- Want to create website tool for BCBS Prefix List HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from infinite-scroll.