Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

how to recovery nextsibling

Avatar

Level 4

Hi,

i have a listener up to a CQ.form.selection with two functions:

selectionchanged="function(comp, val, isChecked) {
    var text = comp.nextSibling();
    console.log('text '+text.getValue());
    ...
    
loadcontent="function(comp) {
    var text = comp.nextSibling();
    console.log('text '+text.getValue());
    ...

I can't understand why the variable 'text' inside the selectionchanged is correct and the other one prints inside the console an empty value

 

Thanks

2 Replies

Avatar

Level 10

Have you created a custom xtype that uses this class: 

https://docs.adobe.com/docs/en/cq/5-5/widgets-api/?class=CQ.form.Selection

What value is the text variable printing out? 

Avatar

Level 4

It isn't a custom xtype

This is my code:

<cta jcr:primaryType="cq:Widget" columnWidth=".3" defaultValue="4" name="./selector/cta" type="select" value="4" xtype="selection"> <options jcr:primaryType="cq:Widget" path="/sharedCode/cta/options.infinity.json" xtype="cqinclude"/> <listeners jcr:primaryType="cq:Widget" path="/sharedCode/cta/listeners.infinity.json" xtype="cqinclude"/> </cta> <text jcr:primaryType="cq:Widget" columnWidth=".2" name="./selector/button_text" xtype="textfield"/> ////listeners <?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="nt:unstructured" selectionchanged="function(comp, val, isChecked) { var text = comp.nextSibling(); var url = text.nextSibling(); var target = url.nextSibling(); if(val=='0'){ text.setValue(''); } if(val=='1'){ text.setValue('Richiedi'); } if(val=='2'){ text.setValue('Fissa un appuntamento'); } if(val=='3'){ text.setValue('Scopri di più'); } if(val=='4'){ text.setValue('Approfondisci'); } }" />

 

Why the selectionchanged works fine and the loadcontent no?