Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

AEM 6.5 edit mode issue with javascript

Avatar

Level 7

Hi all,

 

Many of our pages have our own javascript and third party library, such as jQuery. It looks like AEM disables those scripts when is in edit mode. When clicking on the "Preview", most of functionalities will come back, but not all. Then we will have to get rid of the "editor.html" selector in the URL in order to fully load the scripts. Is there any way to prevent AEM disabling the javascript?

 

A good example is that when using jQuery Cycle2 for slideshows, the sling model loads all the images from the backend, but AEM disables Cycle2's features so that all image heights are added up, making the page's height huge. Testing wcmmode doesn't work in this case.

 

Thanks!

 

-kt

8 Replies

Avatar

Community Advisor

How are you adding javascript third party library?

I.e as an external source url or added in AEM client library, so that AEM can minify it?

did you try copying the library source in internal file?

Avatar

Level 7

Yes, we downloaded all necessary files in our folder, then minify them and compile all files using js.txt.

Avatar

Employee Advisor

Hi @kevingtan , check if any of those client libraries/scripts are included on the page under this condition

${!wcmmode.edit} or ${wcmmode.disabled}

check this reference link: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-sightly-check-if-edit-...

 

Avatar

Level 7

The javascript is added without any condition. By the way, ${wcmmode.edit} and ${wcmmode.preview} don't make much difference when toggling the mode using the top right buttons. One has to reload the page in order to see the difference.

Avatar

Community Advisor

@kevingtan  

Have you checked in the browser network tab weather the custom clientlibs - Cycle2 are loading or not? 

 

When in the Editor, AEM loads the editor related clientlibs to show the authoring tools - drag and drop and component editor toolbar features. These editor features related events may have taken precedence over the custom clientlib events. 

You may have to write custom code based on the editor events to apply the Cycle2's features on top of the Preview.  

Avatar

Level 7

It's loaded. My understanding is that when it's in edit mode, the page is loaded within an <iframe>. I don't know if that's the reason the javascript is disabled within iframe.

 

Screenshot 2024-02-07 at 9.15.37 AM.png

As shown above, the page is loaded within the <iframe> in edit mode.

Thanks,

 

-kt

 

Avatar

Administrator

@kevingtan Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni