checkbox in dialog | Community
Skip to main content
Level 6
Mar 8, 2021 8:30 AM UTC
Solved

checkbox in dialog

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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Mar 8, 2021 8:54 AM UTC

@shaheena_sheikh 

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

3 replies

arunpatidar
New Participant
Mar 8, 2021 1:38 PM UTC

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/coralui3/Coral.Checkbox.html

Translate
Arun Patidar
Anudeep_Garnepudi
Anudeep_GarnepudiAccepted solution
New Participant
Mar 8, 2021 8:54 AM UTC

@shaheena_sheikh 

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

Translate
Level 6
Mar 8, 2021 8:54 AM UTC

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;

Translate