Magento 2 : How to Detect Checkout Step Change
You can register a handle for when the hash code changes, i.e. $(window).hashchange(callBack)
.
This is what happens in Magento_Checkout/view/frontend/web/js/view/progress-bar.js
:
$(window).hashchange(_.bind(stepNavigator.handleHash, stepNavigator));
This causes the stepNavigator.handleHash
function to execute whenever the step changes because changing steps using next
or navigateTo
changes the window's hash.