• My friend recently pointed out to me that the infinite-scroll on her site stopped working. My best guess is that it broke after the 3.6 update of WordPress, but I can’t be sure.

    I read the solution mentioned in this post: http://wordpress.org/support/topic/infinite-scroll-js-error-uncaught-error-infinite_scroll-is-not-defined but that didn’t solve my problem.

    The only way I could get it back to work was changing footer.php (in infinite-scroll/templates/) to:

    setTimeout(function() {
    // Because the <code>wp_localize_script</code> method makes everything a string
    	infinite_scroll = jQuery.parseJSON(infinite_scroll);
    
    	jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll, function(newElements, data, url) { eval(infinite_scroll.callback); });
    
    }, 500);

    I realize this is not a real solution, so I’m hoping someone will be able to give more insight into why this is happening all of a sudden and how to solve it properly.

    The site: http://www.eyethink.nl

    Thanks for reading,
    Marloes

    http://wordpress.org/plugins/infinite-scroll/

Viewing 7 replies - 1 through 7 (of 7 total)
  • This was a life saver, I couldn’t get the method that the site mentioned either, but using that timeout was a valid solution for the time being. Thank you so much!

    Thank you, I found the issue with my instance was when BWP minified my scripts it included the minified <script> tag lower than the infinite scroll <script> included through it’s footer.php you amended.
    Worked like a charm,

    Cross-Referencing my ticket:
    http://wordpress.org/support/topic/bwp-minify-breaking-infinite-scrolling?replies=2#post-5129401

    I’ve found a slightly more sustainable solution than the timeout as after adding a few more scripts I needed to increase the timeout to accommodate the load.
    Anyway replacing the timeout with an onload allowed the infinite-scroll scripts to load prior to execution everytime now matter lag or page overhead:

    window.onload = function() {
    // Because the <code>wp_localize_script</code> method makes everything a string
    	infinite_scroll = jQuery.parseJSON(infinite_scroll);
    
    	jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll, function(newElements, data, url) { eval(infinite_scroll.callback); });
    };

    Cheers

    I’m needing some help with the configuration of this plugin on a new site that I’m working. I use version WordPress 3.8.

    The URL is: http://moocabier.com.br/new/

    The CSS selectors I’m currently using but aren’t working are:

    Content Selector: #blog-content
    Navigation Selector: div.nav-links
    Next Selector: div.nav-previous a
    Item Selector: div.post

    I followed your steps and not solve it. Displays the same error:
    Uncaught Error: infinite_scroll is not defined.

    Someone can help me, please?

    Hi Web Togo,

    I believe your issue is slightly separate so this workaround sadly doesn’t apply.
    My problem lay with BWP Minify + Infinite Scroll leading the jquery.infinitescroll.js to be placed below the init segment:

    infinite_scroll = jQuery.parseJSON(infinite_scroll);
    	jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll, function(newElements, data, url) { eval(infinite_scroll.callback); });

    Inspecting your page – http://moocabier.com.br/new/
    I found the order is correct in that the jquery.infinitescroll.js is placed above the call to infinite_scroll.
    Your HTML

    <script type='text/javascript' src='http://moocabier.com.br/new/wp-content/plugins/infinite-scroll/js/front-end/jquery.infinitescroll.js'></script>
    <script type="text/javascript">
    window.onload = function() {
    // Because the <code>wp_localize_script</code> method makes everything a string
    	infinite_scroll = jQuery.parseJSON(infinite_scroll);
    
    	jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll, function(newElements, data, url) { eval(infinite_scroll.callback); });
    };
    </script>

    You’ve wrapped it with window onload properly so it’s not that the workaround isn’t in place it’s just unapplicable as there’s another piece missing completely from your DOM.

    On my instance – http://myvancity.ca
    The Infinite Scroll plugin saves the settings as a json object within a <script> tag named infinite_scroll… which is what the error is indicating as missing.
    My Infinite Scroll Settings JSON HTML

    <script type="text/javascript">
    /* <![CDATA[ */
    var infinite_scroll = "{\"loading\":{\"msgText\":\"<em>Loading...<\\\/em>\",\"finishedMsg\":\"<em>No additional posts.<\\\/em>\",\"img\":\"http:\\\/\\\/myvancity.ca\\\/wp-content\\\/plugins\\\/infinite-scroll\\\/img\\\/ajax-loader.gif\"},\"nextSelector\":\".page_nav_wrap .post_nav a.next\",\"navSelector\":\".page_nav_wrap\",\"itemSelector\":\".post\",\"contentSelector\":\"#content\",\"debug\":false,\"behavior\":\"\",\"callback\":\"\"}";
    /* ]]> */
    </script>

    Have you gone into Settings > Infinite Scroll and saved your information?
    If so try deactivating and reactivating or installing the plugin over itself via ftp.

    If all fails I’d say open another ticket indicating the settings are not being injected into your page. And implement a new workaround, creating the necessary infinite_scroll object manually.
    Update the footer.php (in infinite-scroll/templates/)… again.
    Placing the following <script> tag above the existing one you updated with the window.onload or merging the two <scripts>

    <script type="text/javascript">
    /* <![CDATA[ */
    var infinite_scroll = "{\"loading\":{\"msgText\":\"<em>Loading...<\\\/em>\",\"finishedMsg\":\"<em>No additional posts.<\\\/em>\",\"img\":\"http:\\\/\\\/myvancity.ca\\\/wp-content\\\/plugins\\\/infinite-scroll\\\/img\\\/ajax-loader.gif\"},\"nextSelector\":\".page_nav_wrap .post_nav a.next\",\"navSelector\":\".page_nav_wrap\",\"itemSelector\":\".post\",\"contentSelector\":\"#content\",\"debug\":false,\"behavior\":\"\",\"callback\":\"\"}";
    /* ]]> */
    </script>

    Update the added code with your selectors:
    Content Selector: #blog-content
    Navigation Selector: div.nav-links
    Next Selector: div.nav-previous a
    Item Selector: div.post

    <script type="text/javascript">
    /* <![CDATA[ */
    var infinite_scroll = "{\"loading\":{\"msgText\":\"<em>Loading...<\\\/em>\",\"finishedMsg\":\"</em><em>No additional posts.<\\\/em>\",\"img\":\"http:\\\/\\\/moocabier.com.br\\\/wp-content\\\/plugins\\\/infinite-scroll\\\/img\\\/ajax-loader.gif\"},\"nextSelector\":\".nav-previous a\",\"navSelector\":\".nav-links\",\"itemSelector\":\".post\",\"contentSelector\":\"#blog-content\",\"debug\":false,\"behavior\":\"\",\"callback\":\"\"}";
    /* ]]> */
    </script>

    Hope that’s helpful,
    O and of course on plugin update this will revert, hence I’d suggest another ticket strictly concerning your issue of missed infinite_scroll settings injection to notify the plugin developer.

    myvancity,

    Thanks a lot! It’s working now! Your help was extremely useful.

    I had to manually add that last script that you suggested in footer.php (in infinite-scroll/templates/).

    Thanks.

    Awesome Web Togo, glad to hear everything worked out.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Uncaught Error: infinite_scroll is not defined – 'solved' with setTimeout’ is closed to new replies.