Jump to content

Javascript stops working after selecting any product combination


santiagonra

Recommended Posts

Hi guys! I added a button using contentBox (https://contentbox.org/) on my product page. The thing is that I have a javascript associated to the button, so that the popup window that is opened when you click it changes dinamically regarding the product. The code works fine until you select any combination. Let's say you change the color of the product, or the size. Then the button just doesn't work. If you click it, it doesn't do anything. I've tried attaching the script in the content box module, putting the script in product.tpl, putting the script in a separate folder and calling it from product.tpl and the result is always the same.

Maybe it is related to the fact that the URL changes when you select any combination.

 

Here's the HTML of the contentBox:

<div class="btn" id="boton-tabla-talles">
	<span>tabla de talles</span>
</div>

And here's the javascript:

$(document).ready(function () {
    console.log("Script de tabla de talles.");
	$("#boton-tabla-talles").addClass("btn");
	var imageURL = $(".product-images.js-qv-product-images li:last-child img").attr('data-image-large-src');
	 $(".product-images.js-qv-product-images li:last-child").css("display","none");
	$("#boton-tabla-talles").click(function (event) {
		event.preventDefault();
		imageURL = $(".product-images.js-qv-product-images li:last-child img").attr('data-image-large-src');
		window.open(imageURL, "popupWindow", "width=513,height=513,scrollbars=yes");
    });
		
});

Thanks in advance!

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...