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 3498556
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:30:16+00:00 2026-05-18T12:30:16+00:00

I am very sorry. This is follow up for my question here : Why

  • 0

I am very sorry. This is follow up for my question here :
Why I can't get this jquery code to work?

All the solutions worked actually its my mistake not explaining it well enough.

What happens is that I have this code to load more posts when it is clicked:

// load more
$(".loadmore").click(function(){
    if ($.cookie('n_more')) {
        count = $.cookie('n_more');
        count++;
        $.cookie('n_more', count, { path: '/', expires: 100 });
    } else {
        $.cookie('n_more', 1, { path: '/', expires: 100 });
    }
    $(".QueryElement").trigger('change');
    var posts_visible = <?php echo $news['num_per_page']; ?>;
    var posts_more = <?php echo $news['num_per_more']; ?>;
    var newposition = posts_visible + (posts_more * $.cookie('n_more'));
    var lastpos = newposition;
    var thispost = $("#post-" + lastpos).position();
    $('html,body').animate({
        scrollTop: thispost.top
    },1000);
});

That code works fine for me because it calls the .QueryElement change trigger and the change trigger contains:

    $(".QueryElement").change(function() {

    // i hide almost all code here i think they are not related to the issue
    $("#result").load('<?php bloginfo('template_directory'); ?>/GetResults.php?' + $.cookie('nw-query'));

    });

The logic is I am attempting to trigger change when the user clicks on load more posts, thats fine and the new posts get loaded, perfect.

But the scroll animation does not work, i think because the load() content happens at the same time and the animate scroll does not recognize the new post IDs that are being loaded?? I am not sure..

but I really want to know how to initialize that animate onclick and also guarantee that the load() function is done. I am not sure what to do from here.

EDIT: Yes it works if I set the position to visible DIV/ID BEFORE the load() but can’t get it to scroll while the new content is loaded into page and new divs are inserted.

This works for example var lastpos = newposition - 1; because I set it to one div back (before content is loaded via load more)

  • 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-05-18T12:30:16+00:00Added an answer on May 18, 2026 at 12:30 pm

    In your change(...) function I would take advantage of the $.load complete argument and perform the scroll there. In-fact, it almost appears everything after the .trigger. could reside within that callback.

    EDITv2

    using the code you posted, this is the change. I’ve moved everything from the trigger in to the load’s complete event. without knowing everything else going on in your code, as far as I can tell this should work.

    // load more
    $(".loadmore").click(function(){
      if ($.cookie('n_more')) {
        count = $.cookie('n_more');
        count++;
        $.cookie('n_more', count, { path: '/', expires: 100 });
      } else {
        $.cookie('n_more', 1, { path: '/', expires: 100 });
      }
      $(".QueryElement").trigger('change');
    });
    
    $(".QueryElement").change(function() {
      // i hide almost all code here i think they are not related to the issue
      $("#result").load('<?php bloginfo('template_directory'); ?>/GetResults.php?' + $.cookie('nw-query'),function(){
        var posts_visible = <?php echo $news['num_per_page']; ?>;
        var posts_more = <?php echo $news['num_per_more']; ?>;
        var newposition = posts_visible + (posts_more * $.cookie('n_more'));
        var lastpos = newposition;
        var thispost = $("#post-" + lastpos).position();
        $('html,body').animate({
            scrollTop: thispost.top
        },1000);
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this question is very easy, but I can't find the answer anywhere.
All, Sorry - this is probably a very strange question. I'm working on a
Sorry the title is not very clear. This is a follow up to my
First of I'm very sorry but this questions is not so so specific. All
Sorry this is not a very well defined question, I am thinking about an
This is a question corresponds to my uni assignment so I am very sorry
Sorry, I know this is a very lame question to ask and not of
I'm very sorry about this being a very cliché question, but I really need
Sorry if this question is very simple, but i am new to coredata world.
I'm very sorry for my previous miswording. So I rephrased this question as follows:

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.