we have defined components clientLibs as cq.authoring.dialog, But these js libs will be loaded for all templates(all projects) while authoring the pages.
Can we restrict them based on template or components as these JS may create issue in other AEM projects?
I tried extraClientLibs but its not working properly..
Is there anyway other then overlaying out-of-box components?
Thanks,
Malli
Solved! Go to Solution.
Hi mallipanchal,
I solved this problem by inserting two lines of HTL code in the component HTML itself. PFA the screenshot:
You need to have a clientLibraryFolder created with this category name:
Now, ONLY wherever you have this component, the JS/CSS files for this component will be loaded.
Good Luck...
In this use case - the best way is to overlay components. If you want to change the style of the overlay component - introduce a new clientlib that contains CSS or JS. This is best practice for AEM.
Views
Replies
Total Likes
Hi
Please have a look at this community article for AEM Client Libraries best practices.
If you want to create component specific clientlibs then you need to create a new clientlibs that gets applied to that particular component. See the article to know how to do it.
Link:- http://blogs.adobe.com/experiencedelivers/experience-management/clientlibs-explained-example/
This article will explain:
I hope this would help you.
~kautuk
kautuksahni wrote...
Hi
Please have a look at this community article for AEM Client Libraries best practices.
If you want to create component specific clientlibs then you need to create a new clientlibs that gets applied to that particular component. See the article to know how to do it.
Link:- http://blogs.adobe.com/experiencedelivers/experience-management/clientlibs-explained-example/
This article will explain:
multiple components with their own JavaScript and CSS files
global JavaScript and CSS files
apps folder is not available on the publish instance
CSS resources have to go in the <head>, JavaScript resources at the end of the page
Resources need to be minified
Some resources need to be merged
I hope this would help you.
~kautuk
By this method we can load site specific styles and JS. But I want include TouchUI dialog specific JS in editmode. Currently we used id as cq.authoring.dialog(but these JS loads in all pages or in all project components while editing )
Views
Replies
Total Likes
I spoke to some of our experts - it lines up with my 1st response.
If not needed for all projects or templates it is better not to attach to cq.authoing.dialog and use cq:includeClientLib with a new category
(introduce a new clientlib that contains CSS or JS.)
Views
Replies
Total Likes
I've a similar issue, but i fix it just creating a new clientlibrary named custom.authoring.dialog and including it by using extraClientLibs in our components.
Views
Replies
Total Likes
antoniom54959291 wrote...
I've a similar issue, but i fix it just creating a new clientlibrary named custom.authoring.dialog and including it by using extraClientLibs in our components.
Yeah, Even I tried this. BUT
Using extraClientlib property on the cq:dialog, This can be done but issue here is dialog DOM elements and JS lib were loaded at the same point syncing is not happening. so when we open dialog first time its not working, close the dialog and open it again it works fine(JS were loaded in first time, so it works fine second time onwords).
Note: we are using custom-multifield.
Views
Replies
Total Likes
smacdonald2008 wrote...
I spoke to some of our experts - it lines up with my 1st response.
If not needed for all projects or templates it is better not to attach to cq.authoing.dialog and use cq:includeClientLib with a new category
(introduce a new clientlib that contains CSS or JS.)
Where should I include it in page component or in any of the particular components script.( I hope we need this only in EDIT mode)??
Views
Replies
Total Likes
Include the clientlib in the script that corresponds to the component. If its a page component - place it there.
Views
Replies
Total Likes
Hi mallipanchal,
I solved this problem by inserting two lines of HTL code in the component HTML itself. PFA the screenshot:
You need to have a clientLibraryFolder created with this category name:
Now, ONLY wherever you have this component, the JS/CSS files for this component will be loaded.
Good Luck...
+ antoniom54959291, kautuksahni, smacdonald2008
Hi mallipanchal,
There is one more solution to this. In the client-library that has the category `cq.authoring.dialog`, you can include a sort of name-spacing. For ex:
Good Luck...
Views
Replies
Total Likes
Any way we can segregate libraries depending upon claasic/touch UI
I want to keep both dialogs types in component, but the libraries (custom.js) need to be seperately called in case of touch UI and other s when I open dialog in classic.
Views
Replies
Total Likes
For touch UI dialog specific clientlibs you can add via extraClientlibs property
How to Load TouchUI dialog Specific Clientlibs