Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7984157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:10:45+00:00 2026-06-04T11:10:45+00:00

The auto-pagination infinite scrolling script has a variable called offset . I want to

  • 0

The auto-pagination infinite scrolling script has a variable called offset. I want to pass it to the scrollPagination method (for when it’s called again), but I don’t know how to do it.

I need to do this because the offset variable changes inside the afterLoad section, and right now the offset for the contentPage parameter is always 0.

var offset = 0;
$('#stuffhere').scrollPagination({ 
    'contentPage': 'themes/[var.theme]/ajaxcontrols.php?page=products&offset='+offset, // the page where you are searching for results
    },
    'afterLoad': function(elementsLoaded, offset){ // after loading, some function to animate results and hide a preloader div
         offset = offset + [var.homelist]; alert(offset);
    }
});

The code sample is trimmed.

Update

Here’s the result I’m getting.
offset is still zero

I do know variable scope. I want to pass the variable offset to .scrollPagination({ and just don’t know how to do it. Using .scrollPagination function(offset){ doesn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:10:47+00:00Added an answer on June 4, 2026 at 11:10 am

    Better yet… Use before load, removing the original contentPage string. Otherwise the search will often be duplicated. Example:

        'beforeLoad': function(){ // before load function, you can display a preloader div
            $('#loading').fadeIn();         
             offset += 10;  
             this.contentPage = "democontent.php?offset=" + offset;
        },
    

    Update

    You know, I think there’s actually a simpler solution in this case that doesn’t require hacking the plugin or even monkeypatching it:

    // Inside afterLoad
    
    offset += 8;
    
    this.contentPage = "..." + offset;
    

    I just noticed that afterLoad is called as opts.afterLoad, which in this case should bind this to opts inside the function.

    Original Answer

    Ok, it looks to me like the URL you intially pass to the ScrollPagination plugin is used for every request, and not exposed externally for you to change in between requests (e.g. in your afterLoad). You could hack the plugin to allow that, or monkeypatch it with a new loadContent(), e.g.:

    var offset = 0;
    
    var loadContent = $.fn.scrollPagination.loadContent;
    
    $.fn.scrollPagination.loadContent = function ( obj, opts ) {
    
      opts.contentPage = 'themes/jessicatheme/ajaxcontrols.php?page=products&offset=' + offset;
    
      return loadContent.call( this, obj, opts );
    
    };
    
    
    $( '#stuffhere' ).scrollPagination({
    
    ...
    

    I’d think about contacting the plugin author to see if they’ll release it under the MIT or Simplified BSD license, so that it can be modified and distributed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im revising my auto-complete style search script. The site has 2 categories... movies and
Auto-binding of request params seems like default behaviour, but I can't find a lot
I want to auto gen some DTOs from some of my existing objects, I
I often auto-generate an class's hashCode() method using IntelliJ IDEA and typically the method
I'm adding an auto increment column (called rowNum) to my table and it's working
It auto detect my current location when i run this app but there isn't
I have a Entry model which has a Pushes field and I want each
My auto builds are running fine, but after some versioning customization, the name of
Personally I hate auto-created desktop shortcut icons, but some folks seem to think that
i have a problem with the kohana pagination. i have made a method for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.