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

AEM 6550 - Sites Dialog Add Boolean Typehints before Submit | AEM Community Blog Seeding

kautuk_sahni
Community Manager
Community Manager

BlogImage.jpg

AEM 6550 - Sites Dialog Add Boolean Typehints before Submit by Sreekanth Choudry Nalabotu

Abstract

Solution
1) Login to CRXDE Lite (http://localhost:4502/crx/de), create folder /apps/eaem-save-checkboxes-as-boolean

2) Create node /apps/eaem-save-checkboxes-as-boolean/clientlib of type cq:ClientLibraryFolder, add String[] property categories with value [cq.authoring.dialog.all], String[] property dependencies with value lodash.


3) Create file (nt:file) /apps/eaem-save-checkboxes-as-boolean/clientlib/js.txt, add

save-checkbox-as-boolean.js

4) Create file (nt:file) /apps/eaem-save-checkboxes-as-boolean/clientlib/save-checkbox-as-boolean.js, add the following code

(function($, $document){
var CHECK_BOX_SEL = "form.cq-dialog input[type='checkbox']";

$document.on("click", ".cq-dialog-submit", convertStringToBoolean);

function convertStringToBoolean(event){
event.stopPropagation();
event.preventDefault();

$(CHECK_BOX_SEL).each(addTypeHint);

$("form.cq-dialog").submit();
}

function addTypeHint(){
var $checkbox = $(this),
value = $checkbox.val(),
$form = $("form.cq-dialog");

if( (value != "true") && (value != "false")){
return;
}

var typeHintName = $checkbox.attr("name") + "@TypeHint";

$form.append($("").attr("name", typeHintName).attr("value", "Boolean"));
}
}(jQuery, jQuery(document)));

Read Full Blog

AEM 6550 - Sites Dialog Add Boolean Typehints before Submit

Q&A

Please use this thread to ask the related questions.

Topics

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

0 Replies