我的编码基本上是在用户单击“立即购买”选项产品时向用户弹出一个选项框(例如:选择颜色)。
当我加载这个 js 时,它显示: Uncaught TypeError: Cannot call method 'down' of undefined。
当我点击立即购买时,它显示:Uncaught TypeError: Cannot call method 'addToCartHandle' of undefined。
<script type="text/javascript">
var urlAction = '<?php echo $this->getActionUrlBuy() ?>';
var groupdeal = new GroupDeal('deal-ajaxcart-load-ajax','deal-ajaxcart-pop-up','deal-ajaxcart-content','','div[class="block block-cart"]',$$('.header').first().down('ul.links'),'ajaxcart'); //error here
groupdeal.addToCartHandle = function(requestUrl, product_id, deal_id){
groupdeal.url = urlAction+'?productId='+product_id;
$('deal-ajaxcart-load-ajax').show();
new Ajax.Request(urlAction,{
method: 'get',
parameters: {productId:product_id, dealId:deal_id},
onException: function (xhr, e){
$('deal-ajaxcart-load-ajax').hide();
$('deal-ajaxcart-pop-up').hide();
window.location.href = groupdeal.url;
},
onComplete: groupdeal.ajaxOnComplete
});
}
groupdeal.ajaxOnComplete = function(xhr){
if (xhr.responseText.isJSON()){
var response = xhr.responseText.evalJSON();
groupdeal.popupContentWindow(response);
}
}
function openPopup(product_id, deal_id){
groupdeal.addToCartHandle("",product_id, deal_id);//error here
}
function closeDealAjaxPopup(){
$('deal-ajaxcart-load-ajax').hide();
$('deal-ajaxcart-pop-up').style.display = "none";
}
function ajaxMoreTemplateJs(){
if ($('deal-ajaxcart-content').down(".paypal-logo")) $('ajaxcart-pop-up').down(".paypal-logo").hide();
if ($('deal-ajaxcart-content').down(".add-to-links")) $('ajaxcart-pop-up').down(".add-to-links").hide();
}
</script>
问题是,当它在旧站点运行时,它工作正常。但是当移动到新站点(新皮肤,新功能)时,它无法工作。关于如何解决它的任何想法?