1. Add a new property- "maxlinksallowed" to the multifield node in your cq:dialog. Refer the screenshot below-
2. Use this JS code-
$(document).on("dialog-ready", function () {
$(".js-coral-Multifield-add").click(function() {
var field = $(this).parent();
var size = field.attr("data-maxlinksallowed");
if (size) {
var ui = $(window).adaptTo("foundation-ui");
var totalLinkCount = $(this).prev('ol').children('li').length;
if (totalLinkCount >= size) {
ui.alert("Warning", "Maximum " + size + " links are allowed!", "notice");
return false;
}
}
});
});
You need to put the above code in a clientlibs JS file with the category "cq.authoring.dialog".
$(".js-coral-Multifield-add").click(function() {
var field = $(this).parent();
var size = field.attr("data-maxlinksallowed");
if (size) {
var ui = $(window).adaptTo("foundation-ui");
var totalLinkCount = $(this).prev('ol').children('li').length;
if (totalLinkCount >= size) {
ui.alert("Warning", "Maximum " + size + " links are allowed!", "notice");
return false;
}
}
});
});
You need to put the above code in a clientlibs JS file with the category "cq.authoring.dialog".
No comments:
Post a Comment
If you have any doubts or questions, please let us know.