Is there any option to init (text/x-magento-init) script after page load? Example, I am working on a simple quickview feature and my controller returns my a layout - phtml file - with rendered html and script with config like this below:

<script type="text/x-magento-init">
    "[data-role=swatch-options]": {
        "Magento_Swatches/js/swatch-renderer": {
            "jsonConfig": ...

New content is appended to modal wrapper and new popup is initialized. Is there any option to fire (maybe some kind of event od body/document) which triggers again init process for Magento_Swatches/js/swatch-renderer script?

  • Did you get to the bottom of how to do this. I need to initialise swatches on ajax loaded product list as not working with infinite scrolls so may be similar? – harri Sep 19 '18 at 10:09

MAy be you try afterRender function to initialize function after load something you want, Take a look on following document : Js Referrence

  • 1
    thank for your reply! Nice try, but I am working with mixin which based on $.widget (mage.catalogAddToCart), so KO template functions are not visible there – Rob Jan 24 '18 at 12:06

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.