Skip to content

Instantly share code, notes, and snippets.

@IOZ
Created March 20, 2014 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save IOZ/9661599 to your computer and use it in GitHub Desktop.
Save IOZ/9661599 to your computer and use it in GitHub Desktop.
Call jquery trigger events after init Magento public methods
/**
* Call jquery trigger event after initialize Magento public methods
*/
(function () {
/**
* RegionUpdater
*/
if(typeof RegionUpdater !== 'undefined') {
RegionUpdater.prototype.updateOriginal = RegionUpdater.prototype.update;
RegionUpdater.prototype.update = function () {
RegionUpdater.prototype.updateOriginal.apply(this, arguments);
jQuery(this.countryEl).trigger('region:update');
};
}
/**
* Product
*/
if(typeof Product !== 'undefined') {
Product.Config.prototype.reloadOptionLabels2 = Product.Config.prototype.reloadOptionLabels;
Product.Config.prototype.reloadOptionLabels = function (element) {
Product.Config.prototype.reloadOptionLabels2.apply(this, arguments);
jQuery(element).trigger('product:update');
};
Product.Config.prototype.fillSelect2 = Product.Config.prototype.fillSelect;
Product.Config.prototype.fillSelect = function (element) {
Product.Config.prototype.fillSelect2.apply(this, arguments);
jQuery(element).trigger('product:update');
};
Product.Config.prototype.resetChildren2 = Product.Config.prototype.resetChildren;
Product.Config.prototype.resetChildren = function (element) {
Product.Config.prototype.resetChildren2.apply(this, arguments);
if(element.childSettings) {
for(var i=0;i<element.childSettings.length;i++){
jQuery(element.childSettings[i]).trigger('product:update');
}
}
};
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment