AEM component wise JavaScript via clientlib
Hi,
I have developed one component, Used clientlib library to load the JavaScript inside the component.
This below code is used in component HTL.
<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"/>
<sly data-sly-call="${clientlib.js @ categories='project.componentname'}"/>
Only one time this JavaScript is calling. But from as a requirement I need to get the count of the specific component and need to inject attribute according to the count via jQuery.
This is the JavaScript function. But this is working for first component in the page.
var componentCount = 0;
$('.componentClassName').each(function() {
componentCount ++;
$(this).attr("component-number", componentCount );
});
without putting to etc/clientlib, Can we handle this issue?
How I can tackle this.