Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to solve $ is not defined

Avatar

Avatar
Validate 10
Level 1
pillaivinit
Level 1

Likes

0 likes

Total Posts

30 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Applaud 5
Affirm 1
View profile

Avatar
Validate 10
Level 1
pillaivinit
Level 1

Likes

0 likes

Total Posts

30 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Applaud 5
Affirm 1
View profile
pillaivinit
Level 1

20-12-2020

I have a js function using $ in it.

My function uses $get(). and works fine when this function is called from HTL but if I add the function in document.load 

$(document).load(function () {
    alert("alert");
});

then I get $ is not defined in console.

Only the function which is called  in HTL(Sightly) works.

I'm using AEM 6.3.

AEM 6.3 jquery
View Entire Topic

Avatar

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

156 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile

Avatar
Springboard
MVP
Suraj_Kamdi
MVP

Likes

142 likes

Total Posts

156 posts

Correct Reply

41 solutions
Top badges earned
Springboard
Validate 1
Establish
Contributor
Ignite 3
View profile
Suraj_Kamdi
MVP

21-12-2020

@pillaivinit 

First thing, Jquery should always load before the execution of your code.

Second thing, It happens mainly because of your clientlib category /dependencies order.