Support » Plugin: Foo Gallery » How can I tell when a gallery is finished loading (JS)?

  • Resolved ecclescake

    (@ecclescake)


    Hello,

    I’m trying to run a snippet of jQuery that will prepend a sequential number in front of each image’s caption in a gallery.

    My jQuery code is loading fine, and the loop that generates + prepends the numbers is getting executed (it console.logs fine), but the numbers don’t actually get added to the captions. I’m running the snippet on document.ready() … is that too early? I’ve also tried window.load() to no avail.

    When I execute the code in the console, it works. So I just need to call it after the Foo Gallery has finished loading…is there a callback? Not sure where to look.

    For reference, my code is:

    jQuery(window).load(function($) {
        jQuery('.foogallery-justified').children().each(function(i) {
            jQuery(this).find('.caption').prepend('#'+(i+1).toString()+' ');
        });
    });
Viewing 3 replies - 1 through 3 (of 3 total)
  • So instead of doing this via jQuery, I opted to create a custom gallery template that numbered the images in the foreach loop in the template file. This works fine for my purposes so far.

    Plugin Author bradvin

    (@bradvin)

    Glad you found a solution. You could also hook into the foogallery_attachment_html_link_attributes filter in order to change the caption.

    You might need to also then hook into the foogallery_located_template and foogallery_loaded_template actions in order to initialize and reset a global counter variable

    Another good tip; thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.