santiagonra Posted July 1, 2020 Share Posted July 1, 2020 Hi! I have a script that dinamically detects the last picture on each product variant and saves it on a variable. But when I select a different color, the script just stops working. (I guess it's related to the fact that the URL partially changes). So what I'm trying to do, is to detect when the URL changes to trigger an event, but I can't make it work. This is my test code on my product.tpl: {literal} <script type="text/javascript"> $(document).ready(function() { console.log("JQUERY ON TPL"); }); $(window).bind('hashchange', function() { console.log("URL HAS CHANGED"); }); </script> {/literal} The "JQUERY ON TPL" message is displayed on the console, so the jquery script works. But the 'URL HAS CHANGED' message doesn't show whenever I select a color for my product. This is the product URL: http://www.gardeniaintimates.com.ar/top/22-top-helina.html And this is the product URL when I change to a different color: http://www.gardeniaintimates.com.ar/top/22-46-top-helina.html#/2-tamano-m/11-color-negro Link to comment Share on other sites More sharing options...
EvaF Posted July 2, 2020 Share Posted July 2, 2020 try to look athttps://stackoverflow.com/questions/3090478/jquery-hashchange-event Link to comment Share on other sites More sharing options...
santiagonra Posted July 3, 2020 Author Share Posted July 3, 2020 Hi! Thanks for the answer! Yeah, I've tried everything on that page and still no luck 😕 Link to comment Share on other sites More sharing options...
EvaF Posted July 3, 2020 Share Posted July 3, 2020 (edited) ok, in this case take a look, if some other .js on your page doesn't steal it (by ev.preventDefault(), ev.stopPropagation() and so on) Edited July 3, 2020 by EvaF (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now