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

Component beforeedit

Avatar

Avatar
Validate 1
Level 1
AEMnewbie
Level 1

Likes

0 likes

Total Posts

82 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
AEMnewbie
Level 1

Likes

0 likes

Total Posts

82 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
AEMnewbie
Level 1

04-05-2021

I have a listener for a component on a page . When i try to edit the component 

 

<cq:listeners
jcr:primaryType="cq:EditListenersConfig"
beforeedit="function() {console.log('Test')"
afteredit="REFRESH_PAGE"
/>

The after edit  works fine and it refreshes the page after edit , but the before edit isnt working as expected . I have multiple components on the page and the new component should read a value from previous created component on the page .. I am trying to pick a value from last created component and use it in the newly created component. Am i missing something which is causing the beforeedit to fail , or is there any other way to achieve this?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
Umesh_Thakur
MVP

Likes

126 likes

Total Posts

140 posts

Correct Reply

46 solutions
Top badges earned
Validate 1
Applaud 25
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Validate 1
MVP
Umesh_Thakur
MVP

Likes

126 likes

Total Posts

140 posts

Correct Reply

46 solutions
Top badges earned
Validate 1
Applaud 25
Ignite 3
Ignite 1
Give Back 5
View profile
Umesh_Thakur
MVP

04-05-2021

Hi @AEMnewbie,

I think you can use jquery based dialog state function to accomplish your requirement instead of listeners here easily you can make a call to get the data from back-end an all list of the events you can find in @Nikhil's blolg at https://aemsimplifiedbynikhil.wordpress.com/2018/07/30/touchui-dialog-listeners-aem-6-3/

and one implemented solution you can find below:

Umesh_Thakur_0-1620188126897.png

Here we are making an ajax call to a servlet to read some data from a node in crx and assigning the same value to a dialog filed before edit.

 

Hope this will help.

Umesh Thakur

 

Answers (3)

Answers (3)

Avatar

Avatar
Boost 5
Level 2
Ritesh_M
Level 2

Likes

18 likes

Total Posts

21 posts

Correct Reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Boost 5
Level 2
Ritesh_M
Level 2

Likes

18 likes

Total Posts

21 posts

Correct Reply

3 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 1
View profile
Ritesh_M
Level 2

04-05-2021

 

@AEMnewbie ,

 

I see a closing "}" missing at the end of function. Try is that resolves the issue.

Avatar

Avatar
Validate 1
Level 6
Prince_Shivhare
Level 6

Likes

72 likes

Total Posts

365 posts

Correct Reply

57 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 1
Level 6
Prince_Shivhare
Level 6

Likes

72 likes

Total Posts

365 posts

Correct Reply

57 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 50
View profile
Prince_Shivhare
Level 6

04-05-2021

Hi @AEMnewbie ,

 

We had the same use case regarding the multifield. if you want to do it with the component-wise. then it would be difficult for you.

 

- if you want to use the last component content into the newly created then you will have to use the last authored component classes or if want to use custom class then granite:class on the field level would work.

- once you get the classes, use these classes to write a custom js.

- your component values are saved in DOM, now use js function queryselector OR queryselectorall and fetch those properties and set it to the new component.

- logic may vary with the use case.

 

This weekend we are coming with an article for this.

 

https://www.w3schools.com/jsref/met_document_queryselector.asp

https://www.w3schools.com/jsref/met_document_queryselectorall.asp

 

Thanks,

Prince

 

Avatar

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

373 likes

Total Posts

479 posts

Correct Reply

133 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile

Avatar
Affirm 100
Level 10
asutosh_jena
Level 10

Likes

373 likes

Total Posts

479 posts

Correct Reply

133 solutions
Top badges earned
Affirm 100
Ignite 1
Establish
Give Back 50
Give Back 5
View profile
asutosh_jena
Level 10

04-05-2021

Hi @AEMnewbie 

 

Please see an article on the listeners explained very well with example:

http://www.sgaemsolutions.com/2019/01/ootbcustom-cqlisteners-in-cqeditconfig.html

 

Hope this helps!

Thanks