Expand my Community achievements bar.

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

Avatar

Administrator

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.



Kautuk Sahni
Topics

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

0 Replies