How to create complex application in Enonic XP and retain sanity

The preview mode in Enonic XP does evil stuff you don’t really have any control over. This can make you loose sanity if you don’t have a proper understanding and strategy to prevent this based on a deeper understanding of how things is done in XP and how to avoid this behaviour.

So the problem could be that you see strange errors that wasn’t there when you made this complex application in Enonic CMS. First thing you need to know is that XP adds evil event listeners on your dom nodes that you application didn’t expect to be there.

Typical problems could be as explained here:

Best way to fix this is to fool XP to not add any event listners. What you would typically like to do is to add your application node programatically after XP has done the evil stuff. After you have added your dom node programatically you initialize your application the normal way on the dom node you inserted. Typically this could be done in an Angular template.

This approach should give you none evil behaviour from XP, and you should be able to retain your sanity, application integrity and a clean dom tree witch belongs to you and not XP.

Typical applications you would like to use this approach is with Google Earth libs and Geodata libs.

Preben Borch, EVRY, Working for Posten Norway, postal services Norway

You probably mean edit-mode and not preview. In preview it will not add any JavaScript to the page. In edit-mode, it has to do something to the page so it can enable drag and drop of parts.

If it’s in preview-mode it is a bug or you have some sort of apps that contribute to your page that you are not currently aware of.

1 Like