Initiate mockup patterns on AJAX loaded content

I have some AJAX loaded content that intends to use some plone mockup patterns (5.0.5), but they are not firing after doing a jQuery replaceWith on the html segement. In the past I have been able to fix this specifically for modals by running $('.pat-plone-modal').patPloneModal() but I don't seem to be able to generalize that for other patterns. For example, I want to reapply pat-markspeciallinks for all of the content I just injected in the DOM. What's the best way to do this? Ideally I could give a command to check for all mockup patterns on the html I just injected.

1 Like

The mockup pattern registry has good support for this. Just require the registry and call registry.scan() after replacing the segment:

require(['pat-registry'], function (registry) {

where rootElement is the root of the section of the DOM that you are replacing.