Issue with closest(".coral-Select"); in aem 6.5 | Community
Skip to main content
guruprasadc9901
New Participant
Jan 3, 2020 4:27 PM UTC

Issue with closest(".coral-Select"); in aem 6.5

Hi team,
when am trying to get an value from drop down in selection field using closest(".coral-Select") getting an undefined value.
is there any change in aem 6.5? but it works fine in aem 6.3.
EX: var a = $("[name='./componentMode']").closest(".coral-Select");

if iam trying to print $("[name='./componentMode']") ,value is getting populated in console,when iam trying with $("[name='./componentMode']").closest(".coral-Select"); getting undefined in console.
can you suggest any solution.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

arunpatidar
New Participant
Jan 5, 2020 2:29 AM UTC

can you try with. you may be using granite components.

$("[name='./componentMode']").closest(".coral3-Select");

Translate
Arun Patidar
guruprasadc9901
New Participant
Jan 6, 2020 9:32 AM UTC

Hi Arun,
I tried with above coral3-select but it didn't worked ,getting same issue (value as undefined).

Iam having one more issue in JS in show/hide tab .
EX:can you please find below spinet,
function events() {
var select = $('.coral-Form-fieldwrapper #banner_select coral-select-item[selected]').val();

here i can able to get "select" value
if (select != undefined) {
if (select == "homebanner") {
$('a[aria-controls="homebannerid"]').show();
$('a[aria-controls="productbannerid"]').hide();
$('a[aria-controls="blogbannerid"]').hide();
$('a[aria-controls="resourcebannerid"]').hide();
$('a[aria-controls="prefooterbannerid"]').hide();
$('a[aria-controls="historybannerid"]').hide();
}
in this "aria-controls" is not working .
Is there any alternative for this to use?

Thanks,

Guru.

Translate
arunpatidar
New Participant
Jan 6, 2020 12:46 PM UTC

Hi,

try with either one of them based on coral or granite resoirce type you are using.

$("input[name='./componentMode']").closest(".coral3-Select"); 

or

$("input[name='./componentMode']").closest(".coral-Select");

 

you can simple look for DOM structure and parse through, the DOM structure may be changed in 6.5

I can see the aria-controls in DOM but theses are ids not option values.

 

Could you please explain in more details what is your requirement?

 

Example DOM for Coral3 dropdown

 

dropdown1.PNG

Translate
Arun Patidar