2

I'm not sure why on product pages the select dropdowns fire a change event on load, but I'm sure it's something to do with knockout.js. Worse, there's no onchange event for knockout at all tied to the select, but when you change the select on a bundle page it magically adds summary. How is it changing the page on a change event without having any change event on the select? :(

I need to set the select dropdowns to fire something on a change event but instead it fires it the second the page loads.

1

Line 43 of file vendor/magento/module-bundle/view/base/web/js/price-bundle.js

options.trigger('change');

It is a jquery $.widget in the magento2 system. Why it triggers this I have no idea. But it assigns $.proxy calls to methods of the widget when a custom event is called updateProductSummary. This custom event is tied to the product form, and given the context of the ul list of the summary box where it is initiated with data-mage-init on the ul element. After this initialization is when the trigger command happens, it seems to have no real purpose so I commented it out for now but would like to find a way to execute code after I know this has run. Mixins might be the only option but they take a ton of scaffolding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.