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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:00:45+00:00 2026-05-28T02:00:45+00:00

<script> $(window).load(function () { var $wall = $(‘#content’); $wall.imagesLoaded(function () { $wall.masonry({ itemSelector: ‘.oddpost’,

  • 0
<script>
$(window).load(function () {
    var $wall = $('#content');
    $wall.imagesLoaded(function () {
        $wall.masonry({
            itemSelector: '.oddpost',
        isAnimated: true
    });
    $(".oddpost").each (function (idx, el) {   
     if ($(el).position().left < $(el).width()) {
      $('.rightarrow', el).show();
     }
     else {
      $('.leftarrow', el).show();
     }
 });
});

$wall.infinitescroll({
    navSelector: '#pagination',
    nextSelector: '#pagination li a.pagination_nextlink',
    itemSelector: '.oddpost',
    loadingImg: "http://static.tumblr.com/qrevc1p/WTKlx2dsg/gsnjnwui-um.gif",
    loadingText: " ",
    donetext: " ",
    bufferPx: 100,
    debug: false,
    errorCallback: function () {
        $('#infscr-loading').animate({
            opacity: .8
        }, 2000).fadeOut('normal');
    }
}, function (newElements) {
    var $newElems = $(newElements);
    $newElems.hide();
    $newElems.imagesLoaded(function () {
        $wall.masonry('appended', $newElems, {
            isAnimated: true,
            animationOptions: {
                duration: 900,
                easing: 'linear',
                queue: false
            }
        }, function () {
            $newElems.fadeIn('slow');    
        });
    });
  });
$('#content').show(500);
  });
  </script>

I’m using that script on a Tumblr theme I’m working on to apply masonry and infinite scrolling on it. It’s a two column layout so the divs only goes either to the left or to the right. And aside from applying masonry on the theme, it also puts an arrow(.rightarrow) on the div that goes to the left and a different arrow(.left arrow) for the ones that goes to the right.

So far all of that is working fine now. My problem starts when the next page is loaded. Apparently, the arrow codes only applies on the first page but not on the newly appended elements. I’ve tried iterating the arrow codes on different parts of the codes but i Had no lucks on it. It’s really starting to confuse me. I’m not new to jQuery but I’m really having a hard time trying to make this work.

Can anybody tell me which part I should put the arrow codes so it would apply to the newly appended divs too?

  • 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-28T02:00:46+00:00Added an answer on May 28, 2026 at 2:00 am

    You need to run the code that shows the arrows after they have been added to the page.

    I recommend you use a function to avoid copy/paste.

    /**
     * Shows the appropiate arrow for a given element.
     */
    function showArrowOn(el) {
      if ($(el).position().left < $(el).width()) {
        $('.rightarrow', el).show();
      } else {
        $('.leftarrow', el).show();
      }
    }
    
    $(window).load(function () {
      ...
      $(".oddpost").each(function (idx, el) { 
         // Using function to show the arrows on the items at window load.
         showArrowOn(el); 
      }
    }
    
    $wall.infinitescroll({
      ...
      $newElems.imagesLoaded(function () {
        $wall.masonry('appended', $newElems, {
          ...
          }, function () { 
            // Show the arrows once the new elems are appended.
            $newElems
              .fadeIn('slow')
              .each(function () { showArrowOn(this); });
          });
    
    });
    

    You might have some troubles with your logic for showing the arrows on the new elements, because these are not visible at the time you ask jQuery for their position and width (depends on your css), if you are having trouble, try the following:

    $newElems.fadeIn('slow', function () { showArrowOn(this); });
    

    To calculate the arrow to show once the item is visible.

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

Sidebar

Related Questions

so i have this script: <script type=text/javascript> $(window).load(function () { var imagePath = new
I have put together the following mootools script window.addEvent('domready', function() { var shouts =
I am using Jquery UI Tabs for my website. <script type='text/javascript'> //<![CDATA[ jQuery(window).load(function(){ jQuery('#myTabs').tabs({
<script type=text/javascript> function pageLoad() { var $scrollingDiv = $(#scrollfix); $(window).scroll(function () { if ($(window).scrollTop()
I wrote a script like that: NS.load = function(src) { var script = document.createElement(script).setAttribute(src,
I am trying to do something like this. <script type=text/javascript> $(window).load(function(){ <?php if(isset($_SESSION['tagname'])) {
I have this script loaded on a page: (function() { window.alert('bookmarklet started'); function AjaxSuccess(data,
there is a script in my html tag <script type=text/javascript> function setTaxDisplay(display) { window.location.href
This is a crossbrowser window.onload script, I want to add a message, when the
i have popup-window in my script. I use window.open, but almost all browsers block

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.