Giter Club home page Giter Club logo

Comments (9)

pklauzinski avatar pklauzinski commented on August 15, 2024

@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.

pklauzinski avatar pklauzinski commented on August 15, 2024

@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.

darkred avatar darkred commented on August 15, 2024

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.

pklauzinski avatar pklauzinski commented on August 15, 2024

@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.

darkred avatar darkred commented on August 15, 2024

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.

pklauzinski avatar pklauzinski commented on August 15, 2024

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.

darkred avatar darkred commented on August 15, 2024

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.

pklauzinski avatar pklauzinski commented on August 15, 2024

@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.

darkred avatar darkred commented on August 15, 2024

Thanks! Now it's perfect!

from jscroll.

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.