Created
March 20, 2014 11:13
-
-
Save IOZ/9661599 to your computer and use it in GitHub Desktop.
Call jquery trigger events after init Magento public methods
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
/** | |
* 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