2

There is a widget loaded by data-mage-init that I need to run code after it has triggered the change event on the product options, why it does this I don't know, I commented out the line that triggers the change event but the module still works perfectly.

I need to alter some other things on the page when the drop downs are changed. The problem is the drop downs are changed on load because data-mage-init loads this widget which uses trigger() to call the change event on all the select drop downs. I need to define my change events after this runs, otherwise I will have code executing just on page load, instead of when a drop down is changed, which is bad.

I am looking for a simple hook to execute code after ALL mage-init scripts have been looped over and loaded.

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Dec 22, 2017 at 10:54

1 Answer 1

1

I think this is not the perfect answer this is a hint.

@Wolfe -can you find a data-bind attribute, if can I can give you a hint. Knockout Js use render events eg. afterRender, beforeRender like

Then if you can add afterRender event and can call your custom function. eg.

 <span class="counter-number" data-bind="text: getQuantity(),afterRender:setSummeryQty"></span>

afterRender:setSummeryQty here call the setSummeryQty() js function,

answered Dec 22, 2017 at 13:57
4
  • @wolfe - I also wanted to duplicate value and set action after ko js load, so I have tried afterRender and put my custom js function, its works. Commented Dec 23, 2017 at 9:50
  • @wolfe - Have check it Commented Dec 27, 2017 at 18:34
  • yep it works thanks :D Now I just have to figure out how to run something enclosed in a require.js module from this method :) Commented Dec 28, 2017 at 7:57
  • @wolfe - Good , we have to learn ko js to continue the m2 Commented Dec 28, 2017 at 9:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.