const $ = require('jquery'); class Richtext{ constructor(section) { this.section = section.addClass('initiated'); this.imageLinks = this.section.find('a').find('.image-full-wrapper'); if(this.imageLinks.length){ this.imageLinks.parent('a').addClass('image-link'); } } } $('body').on('ihk-init dynamic-component-loaded gfi-dynamic-init', function () { $('.richtext:not(.initiated)').each(function (i) { new Richtext($(this)); }); });