【发布时间】:2016-05-26 19:18:25
【问题描述】:
我有一个 jQuery 小部件(离题:它来自 Magento 2),它的功能如下所示:
$.widget('custom.SwatchRendererTooltip', {
// some more code here....
/**
* Update total price
*
* @private
*/
_UpdatePrice: function () {
var $widget = this,
$product = $widget.element.parents($widget.options.selectorProduct),
$productPrice = $product.find(this.options.selectorProductPrice),
options = _.object(_.keys($widget.optionsMap), {}),
result;
$widget.element.find('.' + $widget.options.classes.attributeClass + '[option-selected]').each(function () {
var attributeId = $(this).attr('attribute-id'),
selectedOptionId = $(this).attr('option-selected');
options[attributeId] = selectedOptionId;
});
result = $widget.options.jsonConfig.optionPrices[_.findKey($widget.options.jsonConfig.index, options)];
$productPrice.trigger(
'updatePrice',
{
'prices': $widget._getPrices(result, $productPrice.priceBox('option').prices)
}
);
},
}
我想以某种方式连接到这个函数,或者至少想知道它什么时候被触发。因此,每当调用_UpdatePrice 时,我都想知道它以便做事。这怎么可能?
【问题讨论】:
标签: javascript jquery jquery-ui magento widget