-
-
Save Dan0sz/3f84e42607d1fb46680889f804008a3f to your computer and use it in GitHub Desktop.
Fix ‘Uncaught TypeError: Cannot read property ‘updateData’ of undefined’ in Magento 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Start update base image process based on event name | |
* @param {Array} images | |
* @param {jQuery} context | |
* @param {Boolean} isInProductView | |
* @param {String|undefined} eventName | |
*/ | |
updateBaseImage: function (images, context, isInProductView, eventName) { | |
var gallery = context.find(this.options.mediaGallerySelector).data('gallery'); | |
// Check if gallery is defined. | |
if (eventName === undefined && gallery !== undefined) { | |
this.processUpdateBaseImage(images, context, isInProductView, gallery); | |
} else { | |
context.find(this.options.mediaGallerySelector).on('gallery:loaded', function (loadedGallery) { | |
loadedGallery = context.find(this.options.mediaGallerySelector).data('gallery'); | |
this.processUpdateBaseImage(images, context, isInProductView, loadedGallery); | |
}.bind(this)); | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Start update base image process based on event name | |
* @param {Array} images | |
* @param {jQuery} context | |
* @param {Boolean} isInProductView | |
* @param {String|undefined} eventName | |
*/ | |
updateBaseImage: function (images, context, isInProductView, eventName) { | |
var gallery = context.find(this.options.mediaGallerySelector).data('gallery'); | |
if (eventName === undefined) { | |
this.processUpdateBaseImage(images, context, isInProductView, gallery); | |
} else { | |
context.find(this.options.mediaGallerySelector).on('gallery:loaded', function (loadedGallery) { | |
loadedGallery = context.find(this.options.mediaGallerySelector).data('gallery'); | |
this.processUpdateBaseImage(images, context, isInProductView, loadedGallery); | |
}.bind(this)); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment