<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DOM modification detection in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363651#M18233</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt;&amp;nbsp;Don't worry, that already exists haha&amp;nbsp;&lt;A href="https://death-to-ie11.com/" target="_blank"&gt;https://death-to-ie11.com/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Aug 2020 09:04:28 GMT</pubDate>
    <dc:creator>piersg</dc:creator>
    <dc:date>2020-08-21T09:04:28Z</dc:date>
    <item>
      <title>DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363160#M18195</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for a way to detect a DOM mutation on a HubSpot page, more specifically the appearance of a pop-up form thank-you modal, with class = .leadin-thank-you-wrapper.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone been successful in doing something similar? Using&amp;nbsp;MutationObserver?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help much appreciated, thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DL&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2020 16:35:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363160#M18195</guid>
      <dc:creator>danielelodola</dc:creator>
      <dc:date>2020-08-19T16:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363599#M18227</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/87078"&gt;@danielelodola&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out to the HubSpot Community.&lt;/P&gt;
&lt;P&gt;I myself am not familiar with this topic, but I will tag in some top Community contributors to see if they have experiences.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;, is there any information you can share with&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/87078"&gt;@danielelodola&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 03:30:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363599#M18227</guid>
      <dc:creator>natsumimori</dc:creator>
      <dc:date>2020-08-21T03:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363618#M18228</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/87078"&gt;@danielelodola&lt;/a&gt;&amp;nbsp;- I have looked for this functionality as well as a global javascript event library for leadin and it doesn't seem to exist... even combing through the javascript library yielded no results. What I am left doing is&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="c-mrkdwn__pre" data-stringify-type="pre"&gt;var leadincheck = window.setInterval(function(){&lt;BR /&gt;  if($(".&lt;SPAN&gt;leadin-thank-you-wrapper&lt;/SPAN&gt;").length){&lt;BR /&gt;    $('body').addClass('has-leadin-thank-you');&lt;BR /&gt;    window.clearInterval(leadincheck)&lt;BR /&gt;  }&lt;BR /&gt;}, 300);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I realize there is no elegance in this approach but it tends to get the job done&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 05:15:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363618#M18228</guid>
      <dc:creator>tjoyce</dc:creator>
      <dc:date>2020-08-21T05:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363643#M18229</link>
      <description>&lt;P&gt;This will work for detecting divs with class '&lt;SPAN&gt;leadin-thank-you-wrapper'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const observer = new MutationObserver(mutations =&amp;gt; {
    mutations.forEach(({ addedNodes }) =&amp;gt; {
        addedNodes.forEach(node =&amp;gt; {
            // For each added node
            if(node.nodeType === 1 &amp;amp;&amp;amp; node.tagName === 'DIV' &amp;amp;&amp;amp; node.classList.contains('leadin-thank-you-wrapper')) {
              // Do things
              console.log(node);
            }
        })
    })
})

// Starts the monitoring
observer.observe(document.documentElement, {
    childList: true,
    subtree: true
})&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 08:24:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363643#M18229</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2020-08-21T08:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363646#M18230</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;- Are we officially allowed to ignore IE now? Plese tell me it's true&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 08:57:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363646#M18230</guid>
      <dc:creator>tjoyce</dc:creator>
      <dc:date>2020-08-21T08:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363647#M18231</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt;&amp;nbsp;Shh, don't say its name. If we ignore it, it will go away.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Officially MS will&amp;nbsp;&lt;SPAN&gt;stop&amp;nbsp;&lt;/SPAN&gt;supporting IE11 on November 30, 2020 (with 365 products ending support on August 17, 2021).&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 09:01:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363647#M18231</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2020-08-21T09:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363648#M18232</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;- I'm starting my countdown &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 09:02:38 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363648#M18232</guid>
      <dc:creator>tjoyce</dc:creator>
      <dc:date>2020-08-21T09:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363651#M18233</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt;&amp;nbsp;Don't worry, that already exists haha&amp;nbsp;&lt;A href="https://death-to-ie11.com/" target="_blank"&gt;https://death-to-ie11.com/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 09:04:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/363651#M18233</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2020-08-21T09:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: DOM modification detection</title>
      <link>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/364023#M18250</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/2450"&gt;@tjoyce&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/63029"&gt;@natsumimori&lt;/a&gt;&amp;nbsp;for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code I implemented :&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function hasId(element) {
    return typeof element.id != 'undefined';
}

function determineModal(element, modalId) {
    if (hasId(element) &amp;amp;&amp;amp; element.id == 'leadinModal-content-wrapper-' + String(modalId)) {
        return true;
    }
}

const observer = new MutationObserver(mutations =&amp;gt; {
    mutations.forEach(({
        addedNodes
    }) =&amp;gt; {
        addedNodes.forEach(node =&amp;gt; {
            // Identify thank-you div.
            if (node.nodeType === 1 &amp;amp;&amp;amp; node.classList.contains("leadin-content-body") &amp;amp;&amp;amp; node.firstChild.classList.contains('leadin-thank-you-wrapper')) {
              if (determineModal(node.parentNode, "######")) {
                // Do stuff case 1
              } else if (determineModal(node.parentNode, "######")) {
                // Do stuff case 2
              } else {
                // Do stuff default case
              };
            };
        })
    })
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added in some conditions in order to treat various modal interactions differently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 07:28:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/DOM-modification-detection/m-p/364023#M18250</guid>
      <dc:creator>danielelodola</dc:creator>
      <dc:date>2020-08-24T07:28:01Z</dc:date>
    </item>
  </channel>
</rss>

