1
0
-1

Basically, I have a native component which potentially could exist in repeat. I want to know if there is anyway for this native component to KNOW when an instance being deleted from the repeat.

The reason being, I’ve defined a global function window.adobeSignGenerateToken() in native component which will needs to be triggered when this component gets removed from the repeat. I could of course document that the form designer needs to drag a “Repeat delete button” and add the function call after the existing click script in the delete button. But just curious if it’s technical possible to achieve it within the native component. Thanks.

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi Dan,

      You can listen on a MutationObserver like this:

                      var observer = new MutationObserver(function (e) {
                          // e[0].removedNodes will contain the nodes removed
                      });

                      observer.observe(document, { childList: true, subtree: true });

      You should attach the observer to a more appropriate element rather than the whole document node.

      Bill

        CommentAdd your comment...
      1.  
        1
        0
        -1

        Since MutationObserver.observe() method needs a html dom element to observe, here is how you can get a dom element based on Maestro item id.

        var item = Form.getItemFromPath( "data." + item_id);
        var itemElement = Util.findElementFromItem(item).length==0 ? null : Util.findElementFromItem(item)[0];
          CommentAdd your comment...