Dynamically add @user to the dom

Hey, I want to add @user mentions using javascript.
To be clear I want to achieve this on normal confluence page using HTML macro.

I can add element with certain classes and everything works fine as long as the element is in the DOM when page finishes loading.

The problem is when I add the same element after page finished loading the Popup window with user info does not appear.

I tried to use debugger to see what functions are called to add event handlers to the elements but this code is extremely minified and everything is hard to read.

Is there some solution to this problem?