Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

Touch UI dialog

Avatar

Level 1

In Component I have three fields, Image height and Image width in one tab and dropdown in another tab and dropdown has options like left, center, right and inline. If author mentions the value of image height and image width then in dropdown inline option should get automatically applied. 

 

 

 

 

MicrosoftTeams-image (7).png

 

MicrosoftTeams-image (8).png

 

Thanks & Regards,

Vineetha Kolipaka.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Vineethakolipaka , 

 

As Arun said, you have to write JS on your dialog to change field values based on author inputs.

Write something like this based on your requirements. 

 

 

(function ($, $document, Coral) {
    var selectfield = {};
    $document.on("dialog-ready", function () {

        selectdata = [];
        const form = document.querySelector('form.cq-dialog');

        init();

        /*Start of Functions**/
        function init() {
            try {
                selectfield.actionPath = form.action;
                 // console.log(selectfield.actionPath);
                processData();
            } catch (err) {
                 // console.log(err.message + ', Component not available');
            }
        }

        function processData() {
            $.ajax({
                url: `/bin/design_dialog?path=${form.action}`,
                async: false,
                dataType: 'json',
                success: function (data) {
                    selectdata = data.groups;
                    readInputValues(selectdata);
                }
            });
        }
function readInputValues(selectdata) {
/*Write your own logic as required*/.
setDropDownValue(data);
}


function setDropDownValue(data) { /*Write your own logic as required*/. } // then apply your desired output values back into dialog $(document).on("click", ".cq-dialog-submit", function (e) { /* proces & apply your data here*/ }); $('input[data-class^="**youridentifier**"]').change(function () { /* change selector values*/ }); })($, $(document), Coral);

 

 

Regards,
Aditya.Ch

2 Replies

Avatar

Community Advisor

Hi,

You need to write javascript event listener to set the dropdown values.

check javascript logic at https://stackoverflow.com/questions/36850805/change-dropdown-values-based-on-input-in-textfield  

Avatar

Correct answer by
Community Advisor

Hi @Vineethakolipaka , 

 

As Arun said, you have to write JS on your dialog to change field values based on author inputs.

Write something like this based on your requirements. 

 

 

(function ($, $document, Coral) {
    var selectfield = {};
    $document.on("dialog-ready", function () {

        selectdata = [];
        const form = document.querySelector('form.cq-dialog');

        init();

        /*Start of Functions**/
        function init() {
            try {
                selectfield.actionPath = form.action;
                 // console.log(selectfield.actionPath);
                processData();
            } catch (err) {
                 // console.log(err.message + ', Component not available');
            }
        }

        function processData() {
            $.ajax({
                url: `/bin/design_dialog?path=${form.action}`,
                async: false,
                dataType: 'json',
                success: function (data) {
                    selectdata = data.groups;
                    readInputValues(selectdata);
                }
            });
        }
function readInputValues(selectdata) {
/*Write your own logic as required*/.
setDropDownValue(data);
}


function setDropDownValue(data) { /*Write your own logic as required*/. } // then apply your desired output values back into dialog $(document).on("click", ".cq-dialog-submit", function (e) { /* proces & apply your data here*/ }); $('input[data-class^="**youridentifier**"]').change(function () { /* change selector values*/ }); })($, $(document), Coral);

 

 

Regards,
Aditya.Ch