Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
    <script type="text/javascript">
        function autoDismount() {
            let interval = setInterval(function () {
                var tracker = document.querySelector("#web-form-status");
                if (tracker.value === 'ABORTED' || tracker.value === 'COMPLETED') {
                    console.info("Autodispatching the dismount event as the web-form's flow's been finished");
                    document.querySelector('web-form-element').dispatchEvent(new Event('dismount'));
                    clearInterval(interval);
                }
            }, 400)
        }
        autoDismount();
    </script>

or it could also be done with element setter override (if browser supports it):

Code Block
languagejs
   <script type="text/javascript">
       Object.defineProperty(document.getElementById('web-form-status'), "value", {
        set: function (newStatus) {
            if (newStatus === "COMPLETED" || newStatus === "ABORTED") {
                console.info("Autodispatching the dismount event as the web-form's flow's been finished");
                document.querySelector('web-form-element').dispatchEvent(new Event('dismount'));
            }
            return true;
        }
    });

Web Form Components Customization

...