AEM 6.4 - How to Read and Set the select dropdown value in Javascript in Coral3 | Community
Skip to main content
Level 4
Mar 8, 2019 2:07 AM UTC
Solved

AEM 6.4 - How to Read and Set the select dropdown value in Javascript in Coral3

I have a dropdown in touch ui dialog. My requirement is to read the select value in javascript(clientlib) and based on that value I want to set the value in second dropdown and disable second dropdown so that author cannot select any other value. Somebody, provide any reference to make it work in coral-3.

<first jcr:primaryType="nt:unstructured" fieldLabel="First" name="./first" 
         sling:resourceType="granite/ui/components/coral/foundation/form/select">
<items jcr:primaryType="nt:unstructured"> <default jcr:primaryType="nt:unstructured" text="(default)" value="" />
<x jcr:primaryType="nt:unstructured" text="x" value="x" />
<y jcr:primaryType="nt:unstructured" text="y" value="y" />
<z jcr:primaryType="nt:unstructured" text="z" value="z" /> </items>
</first>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Mar 8, 2019 4:32 PM UTC

Hi,

I had created similar js to load dropdown based on page selecting in path browser. You can take reference.

Just set granite:id  to your both dropdown and create one hidden item to store/prepopulate second dropdown value.

aem63app-repo/dynamic-dropdown.js at master · arunpatidar02/aem63app-repo · GitHub

Arun Patidar

5 replies

arunpatidar
New Participant
Mar 8, 2019 11:11 PM UTC

Please find package at dynamic-dropdown.zip

Translate
Arun Patidar
smacdonald2008
Level 10
Mar 8, 2019 10:06 PM UTC
smacdonald2008
Level 10
Mar 8, 2019 9:26 PM UTC

In addition to Arun response (which we marked as correct) - we will see if we have other examples too.

We know that working with Granite types is a very popular topic. As a result, we have scheduled our community webinar - Ask the AEM Community Experts - to include this topic in May.

Translate
karanmahiAuthor
Level 4
Mar 8, 2019 7:46 PM UTC

@Arun - Can you please share the touch ui dialog content.xml so that I can understand the nodes and granite:class. Or, if you could attach the working package, that would be great.

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Mar 8, 2019 4:32 PM UTC

Hi,

I had created similar js to load dropdown based on page selecting in path browser. You can take reference.

Just set granite:id  to your both dropdown and create one hidden item to store/prepopulate second dropdown value.

aem63app-repo/dynamic-dropdown.js at master · arunpatidar02/aem63app-repo · GitHub

Translate
Arun Patidar