Comments (9)
@darkred - The element you call $().jscroll
on should be the container into which the content will be loaded, not the selector for the next button. Your next button selector should be provided in the options as nextSelector: 'span.nextprev a'
- Additionally, the nextSelector
needs to be an anchor <a>
tag so that jScroll has an href to use for the next set of content.
Based on looking at your site's code, I think what you want is something like this:
$('#siteTable').jscroll({
nextSelector: 'span.nextprev a',
contentSelector: '.thing'
});
I don't know what your ajax response looks like exactly, but if it is just like the original page content, then you will want your next page content to be filtered by inserting only the .thing
elements, and not necessarily everything that is within div.content
. Keep in mind that contentSelector
includes the element(s) that you are filtering by, and not just what is within it, i.e. if you set contentSelector: '#siteTable'
then the #siteTable
element will be inserted into the existing #siteTable
element, which you don't want!
Please let me know if this helps!
from jscroll.
@darkred - Also, make sure you are not linking to javascript from raw.github.com, as the headers will not be sent correctly and break the script in some browsers - see this post on stackoverflow: http://stackoverflow.com/questions/7180099/including-js-from-raw-github-com
Instead, I suggest you use something like https://rawgit.com/ or maintain the script on your server itself.
from jscroll.
Thank you very much for the detailed and instructive replies!
(about your latter post:
I'll use this now: // @require https://cdn.rawgit.com/pklauzinski/jscroll/master/jquery.jscroll.min.js
)
I just tried your code and it only appends page 2.
Also, before it appends page 2, it adds the entries from the "recently viewed links" table
(please check the red arrows in my screenshot to see what I mean)
Unfortunately I'm unable to make the script work.
Please, if you wish, login to reddit and help me with this.
from jscroll.
@darkred - Ok, I see the reason for both issues. As for the pagination, once you go to the second page, span.nextprev
contains both "previous" and "next" links, but you only want jScroll to target the "next" link, so change your nextSelector
to span.nextprev a:last
.
Secondly, the "recently viewed links" section also uses the thing
class, so you need a contentSelector
that is more specific to the items within #siteTable
. Try changing your code to this:
$('#siteTable').jscroll({
nextSelector: 'span.nextprev a:last',
contentSelector: '#siteTable .thing'
});
from jscroll.
I tried it and, yes, the "recently viewed links" section is no longer appended.
But unfortunately it only appends page 2, as well.
from jscroll.
Ah.. sorry, you also need to include .nav-buttons
in your contentSelector
so that it is loaded into the content to find the nextHref
. Corrected code:
$('#siteTable').jscroll({
nextSelector: 'span.nextprev a:last',
contentSelector: '#siteTable .thing, .nav-buttons'
});
I just tried this out on http://reddit.com and it works.
from jscroll.
Now it works great!!
I've learnt a lot about your great plugin!
I now might be able to use it for other sites too.
Thanks a lot for all your help and for making this!
from jscroll.
@darkred - You may also want to add a callback
option to hide or remove the nav-buttons
div so that it does not disrupt the flow of content. For example:
callback: function() {
$('.nav-buttons').remove();
}
from jscroll.
Thanks! Now it's perfect!
from jscroll.
Related Issues (20)
- click trigger isn´t disabled
- Issue with JScroll
- Callback to tell if there are more pages HOT 1
- Button Trigger Example HOT 1
- Can't have multiple jscrolls on page HOT 1
- contentSelector load all DOM
- change url - SEO
- Parceljs
- _load not triggered when page is zoomed in or out at certain levels HOT 3
- jscroll does not load the new content all the time HOT 4
- is there a vinilla js alternative? HOT 1
- Add Support for Error Callback HOT 1
- Support sending URL params. HOT 2
- Not working on mobile HOT 2
- documentation - detecting and destroying jscroll
- jscroll is not a function HOT 1
- loadingHtml not workig correctly with pjax
- CSS display problens
- HOw to impememnt a link or button to load manually the content
- page formatting messing up nextSelector href HOT 1
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 jscroll.