I created a simple module that loads a small form when the user looks at a product in prestashop.
It loads a JS script when the user looks at a product.
The script is getting loaded but many of the functions are not working appropriately. My selectors are right and the script works in one test environment and not in another so I'm a little lost, or maybe I'm missing something simple.
For example - this will run when the page loads (this is part of the JS script loaded by my module):
//disable AddToCart Button unless criteria are met
function modifyAddToCart(){
if ($('#customer-confirmation-check').prop('checked')) {
alert ('customer confirm check');
$('#add-to-cart-btn').removeClass("toBeCustomized");
$('#customization-required').text("");
$('#add-to-cart-btn span').text("Add To Cart");
$("html, body").animate({ scrollTop: $('#buy_block').offset().top }, 1000);
} else {
alert ('should be toBeCustomized');
console.log( $('#add-to-cart-btn') );
$('#add-to-cart-btn').addClass("toBeCustomized");
$('#add-to-cart-btn span').text("Customize This Item");
$('#customization-required').text("You must customize this product before it can be added to your cart!");
}
}
The alert is kicked off (that the checkbox hasn't been checked), the console logs the button appropriately - but none of the other things happen. The class is not added, the text is not changed. When I look at it in firebug - I do not see the onClick events being associated with it either.
Is there some sort of system JS script that keeps a modules JS from being applied in certain situations?
Trying to figure out why it works in one situation, but not in another.