/swatch-renderer-fixed.js Secret
Created
October 21, 2018 12:14
Star
You must be signed in to star a gist
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