Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Not able to call JS fuction from rich text component

Avatar

Level 9

Hi All,

I have configured two links using anchor tags using Rich text component.

I could see the source code of added links using source button available on Rich Text dialog.

Now i want to call JS function on clicking of this links,i have added js function to this source code.When i am clicking on the links it's giving below error.

"Uncaught TypeError: Cannot read property 'dom' of null "

How to call JS function?

Please help me in this regard.

Thanks,

Kishore

1 Accepted Solution

Avatar

Correct answer by
Level 10

[img]Capture_1.JPG[/img]

I have tried to implement same, it seems to be working. Let me if this is not what you are expecting.

View solution in original post

4 Replies

Avatar

Correct answer by
Level 10

[img]Capture_1.JPG[/img]

I have tried to implement same, it seems to be working. Let me if this is not what you are expecting.

Avatar

Level 10

When you want to use JS code in AEM components (including calling JS methods)- write a custom xtype. In your use case - writing a custom xtype would involve using this data type:

http://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html?class=CQ.form.RichText

Then you have access to all event handlers, properties, and methods that belong to this data type. 

TO learn how to create a simple custom xtype in AEM - see: 

https://helpx.adobe.com/experience-manager/using/creating-custom-xtype.html 

Avatar

Level 9

edubey wrote...

I have tried to implement same, it seems to be working. Let me if this is not what you are expecting.

 

i am also trying the same.Are you seeing any kind of errors on you browser related to widget.js?

Avatar

Level 10
Nopes...my function seems to be working fine. Please share couple of more screenshot s