I got this piece of jquery code. It basically calls the justifiedGallery plugin with some options, and once the images to display are loaded, another plugin (called colorbox) looks for the <a> tag to add a lightbox functionality to every single hyperlink of the image collection.
I need to use turbolinks in Rails 5 and from what I read turbolinks:load is a way to make that work. And it actually does: When I go to that page the justifiedGallery does it's job perfectly but the second part on('jg.complete', ... does not. Meaning that I need to refresh the page exactly once in order to get the lightbox working.  
$(document).on('turbolinks:load', function() {
  $('#justified-collection').justifiedGallery({
    lastRow: 'nojustify',
    rowHeight: 160,
    rel: 'gallery1',
    margins: 2
  }).on('jg.complete', function() {
    $(this).find('a').colorbox({
      maxWidth: '80%',
      maxHeight: '80%',
      opacity: 0.8,
      transition: 'elastic',
      current: ''
    });
  });
});
The second .on part is actually scoped within the turbolinks:load bit, so I would think that it takes that into consideration, but no.
My question is how can I make turbolinks "recognize" this last bit? I'm still a jquery and javascipt beginner, so please be patient :)
