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

Is there an event we can listen to so we know when adobe target scripts are done loading? For SPA..

Avatar

Avatar
Level 1
jchabot86
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
jchabot86
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
View profile
jchabot86
Level 1

03-06-2021

We have a react SPA.  First page that the user goes to, it seems the "adobe" object is available, but target.getJsonOffer() is not there yet.  Eventually it is there and we can execute it but not unless we do some sort of timeout functionality or force the SPA to re-render.  

Is there some sort of mechanism to knowing when the getJsonOffer, triggerView, etc. functions are available so we can start firing them?

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar
Level 1
emarks87
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
emarks87
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
emarks87
Level 1

07-06-2021

I think the at-library-loaded event should do the trick.

 

Library Loaded
Constant: adobe.target.event.LIBRARY_LOADED
String Value: at-library-loaded
Description: This event is ideal to track when at.js has been fully loaded. You can use this event to customize global mbox execution. You can also use this event to disable the global mbox and then listen for this event to fire the global mbox later.
https://experienceleague.adobe.com/docs/target/using/implement-target/client-side/at-js-implementati...

Avatar

Avatar
Level 1
jchabot86
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
jchabot86
Level 1

Likes

0 likes

Total Posts

8 posts

Correct Reply

0 solutions
View profile
jchabot86
Level 1

07-06-2021

Not 100% sure I'm following.  I can't even exectue the getJsonOffers() function to use its asynchronous functionality.  As you can see in the screenshot - adobeVailable() function checks for adobe.target and adobe.target.getJsonOffer.  As you can see, even the 'target' property isn't there yet for me to execute, thus it would cause runtime errors if I tried to.

jchabot86_0-1623084316854.png

 

Avatar

Avatar
Boost 100
Level 7
rush_pawan
Level 7

Likes

120 likes

Total Posts

192 posts

Correct Reply

77 solutions
Top badges earned
Boost 100
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Boost 100
Level 7
rush_pawan
Level 7

Likes

120 likes

Total Posts

192 posts

Correct Reply

77 solutions
Top badges earned
Boost 100
Validate 1
Ignite 1
Give Back 5
Give Back 3
View profile
rush_pawan
Level 7

04-06-2021

Hello,

 

I think, it should be other way around because target response is asynchronous you should be looking from page or component load side (same we have done in our side as well)

 

as and example refer - https://experienceleague.adobe.com/docs/target/using/implement-target/client-side/at-js-implementati...

as it rightly called out, how it should be done.

 

Hope it helps!!