Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery scripts not running on Wordpress - I have used hook
    primarykey
    data
    text
    <p>This one has me tearing my hair out.</p> <p>I've searched; tried everything I can find.</p> <p>In functions.php:</p> <pre><code>function masonry_scripts() { wp_enqueue_script('jquery'); if(is_home()){ wp_enqueue_script('masonry', get_template_directory_uri() . '/js/masonry.pkgd.min.js'); wp_enqueue_script('infinite scroll', get_template_directory_uri() . '/js/infinite-scroll.js'); wp_enqueue_script('inf-mas-load', get_template_directory_uri() . '/js/masonry-reloader.js', array('jquery', 'masonry', 'infinite scroll')); }; }; add_action( 'wp_enqueue_scripts', 'masonry_scripts' ); </code></pre> <p>masonry~.js and infinite-scroll.js are local copies of the scripts available on their respective sites.</p> <p>In masonry-reloader.js:</p> <pre><code>jQuery(function($){ var $container = $('#items'); $container.imagesLoaded(function(){ $container.masonry({ itemSelector: '.item-wrap', columnWidth: 472, gutter: 12 }); }); $container.infinitescroll({ navSelector : '#pag.item-wrap', // selector for the paged navigation nextSelector : '#pag.item-wrap .pagination ul.paglinks li#older', // selector for the NEXT link (to page 2) itemSelector : '.item-wrap', // selector for all items you'll retrieve loading: { finishedMsg: 'No more pages to load.', img: 'http://i.imgur.com/6RMhx.gif' } }, // trigger Masonry as a callback function( newElements ) { // hide new items while they are loading var $newElems = $( newElements ).css({ opacity: 0 }); // ensure that images load before adding to masonry layout $newElems.imagesLoaded(function(){ // show elems now they're ready $newElems.animate({ opacity: 1 }); $container.masonry( 'appended', $newElems, true ); }); } ); }); </code></pre> <p>It just doesn't have any affect - like the script isn't running.</p> <p>Inspect element shows all the scripts load. And masonry~.js is fine, because if I initialise in HTML or no-jQuery-js, it's fine.</p> <p>I need to use jQuery so that I can append new items from infinite scroll, though.</p> <p>And it's not because infinite scroll is bad - if I reduce my jQuery to just initialise Masonry (like works fine in HTML), it doesn't initialise. Acts like it isn't even there.</p> <p>I've been at this for over a week now, I really hope someone can spot my (probably) stupid mistake - I feel like I've tried it all.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload