Expand my Community achievements bar.

SOLVED

AEM 6.5 - default value setup in select component

Avatar

Level 1

We recently did inplace upgrade from AEM 6.3 to AEM 6.5.

The default value set in a dropdown using select component worked fine for touch UI with following setup but not working in 6.5.

selected="{Boolean}true"

In 6.5,the default value setup is not working there by always displaying the top one in the deopdown. Please advise ASAP.

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

6.5
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

It should work in 6.5, It checked against Coral3/Granite resourceType and working fine

granite/ui/components/coral/foundation/form/select

 

the selected property is not gonna work if component is already authored.



Arun Patidar

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hi,

It should work in 6.5, It checked against Coral3/Granite resourceType and working fine

granite/ui/components/coral/foundation/form/select

 

the selected property is not gonna work if component is already authored.



Arun Patidar

Avatar

Level 1

Hi i have a similar issue. The above property works fine but i had to open the dialog and close it to see the changes getting applied. Any solution for that. 
My requirements are to change the container component dropdown value to be always responsive by default. The above property does that job but does not allow me to resize the contained components. I had to open the container component dialog again and click on ok to apply the changes.

Avatar

Level 2

Hi @arunpatidar 
I'm facing same issue with dropdown here.

I've set the selected value, still after the next deployment its not taking that default value. We need to again select/author it manually. 

 

"the selected property is not gonna work if component is already authored." == this one I considered still facing same issue for other country pages.

 

Do we have any quick solution on it?

 

Thanks,

Nikita M

Avatar

Community Advisor

Hi @Nikita_Mazire 
You can write a small javascript to initialise the dropdown with default value if none is selected.

E.g.

(function (document, $) {
  "use strict";
  $(document).on("foundation-contentloaded", function() {
    $(".dropdown-field-selector-class").each(function() {
      let $dropdown = $(this);
      let selected = $dropdown.find("coral-select-item[selected]");
      if (selected.length === 0) {
        $dropdown.find('coral-select-item[data-selected]').first().attr('selected', true);
      }
    });
  });
})(document, Granite.$);

 



Arun Patidar