Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

checkbox in dialog

Avatar

Level 6

I have a checkbox in my dialog box. I have added the property "value" and value as "true" (string). When i open my dialog box, and if check/uncheck the checkbox, i always see the console log "check true". How can i get the correct detail if the checkbox is checked/unchecked?

I am using granite:data node and the below js code:

$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {
selector: "[data-checkbox]",
validate: function(checkbox) {
var check= checkbox.value;
console.log("checks " + check); //always showing true

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Shaheena_Sheikh 

Use var check= checkbox.checked; instead of var check = checkbox.value;

View solution in original post

3 Replies

Avatar

Level 6

I just realised the line should be 

var check = $(".cq-dialog").find("#checkbox")[0].checked; instead of

var check = $(".cq-dialog").find("#checkbox")[0].value;

Avatar

Correct answer by
Community Advisor

@Shaheena_Sheikh 

Use var check= checkbox.checked; instead of var check = checkbox.value;

Avatar

Community Advisor

Either use native javascript or jquery, Please check all the supported method for Coral3 checkbox at https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/coral-ui/c...



Arun Patidar