CQ5 AEM: how to get component by name in dialog using javascript

I know this is probably a simple question, but I'm new to CQ5 and AEM in general.

I have cq: Widget node, which is a simple text field.

 <rowtitlevalue
     jcr:primaryType="cq:Widget"
     fieldLabel="Row Title Value"
     name="./rowtitlevalue"
     xtype="textfield"
     disabled="true"/>

Now, currently in my JavaScript, I am currently viewing it through

var textfield = panel.findByType('textfield')[1];

which works fine (there is another text box before that, therefore 1 in the array.

MY QUESTION: how to search for this field using the NAME attribute in my javascript.

Any help would be appreciated.

In addition, I use this object to run the following:

if (show != undefined) {
    textfield.enable();
    textfield.show();
}
else if (show == undefined) {
    textfield.disable();
    textfield.hide();
}

JavaScript is found in component-based client emails.

And this is the Listener that I have with the checkbox that defines the SHOW value in javascript (which works fine).

<listeners
jcr:primaryType="nt:unstructured"
loadcontent="function(field,rec,path){Ejst.toggleRowTitle(field);}"
selectionchanged="function(field,value){Ejst.toggleRowTitle(field);}"/>

Please let me know if you have any problems with this.

+4
2

API CQ.Dialog getField( String name), . , .

, xtype dialog panel, , .

Ejst.toggleRowTitle = function(checkbox) {
    var dlg = checkbox.findParentByType('dialog');
    var rowTitleField = dlg.getField('./rowtitlevalue');
    // perform required operation on rowTitleField
}
+7

- , js , . - : rowtitlevalue.js, :

 "use strict";

    use(function() {

        var data = {};
        data.rowtitlevalueData = properties.get("rowtitlevalue");
        //more properties if needed...

        return  {
           data: data 
        }
    });

, javascript, :

<sly data-sly-use.data="rowtitlevalue.js">

    <script type="text/javascript">
        var myVariable = ${data.rowtitlevalueData};
   </script>

</sly>
+1

Source: https://habr.com/ru/post/1532744/


All Articles