0

我的编码基本上是在用户单击“立即购买”选项产品时向用户弹出一个选项框(例如:选择颜色)。

当我加载这个 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>

问题是,当它在旧站点运行时,它工作正常。但是当移动到新站点(新皮肤,新功能)时,它无法工作。关于如何解决它的任何想法?

4

1 回答 1

0

快速浏览一下,我可以说您从单击立即购买中得到的错误是因为 groupdeal 从未从第一个错误中定义。在我看来,您应该查看对 .header 的调用,前面有两个 $$(应该是一个)作为您的答案,因为似乎该特定方法不是从另一个站点计算的。2美分

于 2013-06-25T04:01:58.493 回答