Example of javascript event and adaptTo? | Community
Skip to main content
New Participant
May 11, 2018
Solved

Example of javascript event and adaptTo?

  • May 11, 2018
  • 2 replies
  • 2523 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Peter_Puzanovs

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

2 replies

New Participant
May 11, 2018

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');

     ...

} 

Peter_Puzanovs
Peter_PuzanovsAccepted solution
New Participant
May 11, 2018

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