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

Example of javascript event and adaptTo?

Avatar

Level 4

With Granite UI, when I handle a client-side js event of type 'foundation-field-change', what should the code look like to adapt the data to the underlying object?

For example, my callback function signature is,

     $(document).on('foundation-field-change', function(event) {...}  

I want to do some work involving the changed field - how do i get to it/adapt to it?  Docs are here foundation-field — Granite UI 1.0 documentation but I need a little more help.

thanks Joe

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Dear Dorian,

As per javasccript API, we have adaptTo method registered to jQuery provided by Adobe.

Therefore you call:

$(window).adaptTo("foundation-registry") in this example we adapt window to foundation-registry.

Regards,

Peter

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Dear Dorian,

As per javasccript API, we have adaptTo method registered to jQuery provided by Adobe.

Therefore you call:

$(window).adaptTo("foundation-registry") in this example we adapt window to foundation-registry.

Regards,

Peter

Avatar

Level 4

Thanks PuzanovsP,

Does the following sound correct?  For an event, if the docs describe its adaptTo type as 'foundation-field' I should be able to write,

$(document).on('foundation-field-change', function(event) {

     var f = $(event).adaptTo('foundation-field');

     ...

}