Jump to content

Can't detect URL change on Product.tpl script


Recommended Posts

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:

		<script type="text/javascript">
				$(document).ready(function() {
					console.log("JQUERY ON TPL");		
				$(window).bind('hashchange', function() {
					console.log("URL HAS CHANGED");

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...