javascript hit and miss?

This would be a Turbolinks problem, very definitely. Turbolinks only refreshes the head of the page when you do a full reload. It's expected that your scripts will be compiled in the Asset Pipeline and will load once. Ever after, the body of the page is silently replaced via Ajax, thus speeding up the loading of your global libraries (by dint of only loading them on the first page load).

Now the problem comes when you have some code in your page body that your script needs to interact with, so you, being a pro, write proper unobtrusive JavaScript that wires up that connection later. Something like:

$(document).on('click', '.lightbox a', function(){
  // do something with $(this), which will be the a (link) you clicked on
});

That should work without any modification, because it is lazy-loading the target at the moment the event fires, rather than wiring up the listener on page load.

I suspect that may be what your code is doing, so look through it for something that looks more like:

$(document).ready(function(){
  $('.lightbox a').click(function(){
    // do something with $(this), which will be the a (link) you clicked on
  });
});

If you find that, either rewrite it to the lazy pattern I showed you first, or if it's too complex to untwist, change the $(document).ready bit to this:

$(document).on('load turbolinks:load', function(){
  // ...
});

This will hook into the event that fires after Turbolinks refreshes the body of the page, so everything on the screen will be ready to be extended.

Walter

I think I found something that fixes the problem.

I’ve added it to my partial.

ok, you will have a minute to test it…

test@gmail.com

12345678

https://cryptic-inlet-13518.herokuapp.com/products/1316

All of the product pages have a sharethis toolbar.

I don’t know if it’s working now, i tried something I found on google.

The other thing I noticed, now it thinks the page is not secure.

Thanks,

Joe