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.
1 Answer 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,
-
@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.Lasantha– Lasantha2017年12月23日 09:50:36 +00:00Commented Dec 23, 2017 at 9:50
-
@wolfe - Have check itLasantha– Lasantha2017年12月27日 18:34:42 +00:00Commented 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 :)user44406– user444062017年12月28日 07:57:21 +00:00Commented Dec 28, 2017 at 7:57
-
@wolfe - Good , we have to learn ko js to continue the m2Lasantha– Lasantha2017年12月28日 09:47:48 +00:00Commented Dec 28, 2017 at 9:47