简体   繁体   中英

prototype class is undefined on popup

The prototype class

PDPSwatchesData = Class.create();
PDPSwatchesData.prototype = 
{
    initialize : function(additionalData)
    {
      this.additionalData = additionalData;
    }, .....

This is working on general pages(Product detail page), but it shows PDPSwatchesData is not defined when it comes to popup(Quick view of product) where the quick-view contents are obtained via ajax, so for out of DOM elements it's saying not defined error.

I write jquery code so the terminology i have used here might be wrong here(for prototype), this is from a magento plugin. So, how can that class be defined when populating related contents asynchronously ?

Thank you !!

Your script gets loaded in the parent window whereas your popup is the child window whose HTML comes from AJAX. Hence, when you try to access your parent window function in child window it is not able to find it and throws undefined error.

You can add your script in the file from where child html is coming and than add following in your AJAX

 new Ajax.Request(submitUrl, {
        method    : 'post',
        parameters: {},
        evalScripts: true,  //THIS IS IMPORTANT TO RUN YOUR CHILD WINDOW SCRIPT
        onComplete: function (transport) { }
});

Hope this helps!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM