Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

$(...).adaptTo is not a function error when trying to create dialog listener for multi-field max limit.

Avatar

Level 2

I have tried the below code for setting a  max limit on multifield which was working fine yesterday and today out of nowhere i am seeing the $(...).adaptTo is not a function error and Coral is not defined error on console.

 

 

$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {
// check elements that has attribute data-foundation-validation with value starting with "multifield-max"
selector: "[data-foundation-validation^='multifield-max']",
validate: function(el) {
debugger;
// parse the max number from the attribute value, the value maybe something like "multifield-max-6"
var validationName = el.getAttribute("data-validation")
var max = validationName.replace("multifield-max-", "");
max = parseInt(max);
var ui = $(window).adaptTo("foundation-ui");
// el here is a coral-multifield element
if (el.items.length > max-1){
// items added are more than allowed, return error
ui.alert("warning", "Maximum "+max+" fields are allowed.","notice")
el.children[max].disabled = true;
}else{
el.children[el.childElementCount-3].disabled = false;

}
}
});

 

 

is there any dependencies needed for clientlibs ?

Please find the below error snap.

Screenshot (196).png

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 2

Please try adding  cq.authoring.editor in categories for your clientlib.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 2

Please try adding  cq.authoring.editor in categories for your clientlib.

Avatar

Level 5

Hi @rakeshv29668579  I'm also facing the same issue. I'm trying to create thumbnail image for my custom multifield image. So I have given the above like javascript code and getting the same error adaptTo is not a function. I have added cq.authoring.editor in my clientlib but nothing works out. Is there any other solution for this??