I want to call a JS function when a new item is added to the multifield. I have tried:
$(".cq-dialog").find("coral3-Button coral3-Button--secondary").on("click", funcName);
doesn't call my function.
Solved! Go to Solution.
Views
Replies
Total Likes
try the below code
$(document).on("dialog-ready", function(){
$("coral-multifield").children("button[coral-multifield-add]").on("click", function() {
//Logic
});
});
my func is getting triggered when i am opening the dialog. Not when i click on the Add button
Please try the below code and it will work.
(function (document, $, ns) {
"use strict";
$(document).on("click", ".coral3-Button--secondary", function (e) {
e.stopPropagation();
e.preventDefault();
alert("Hi");
});
})(document, Granite.$, Granite.author);
Views
Replies
Total Likes
Targeted only the button element below. Should work now.
(function (document, $, ns) {
"use strict";
$(document).on("click", "button[coral-multifield-add]", function (e) {
e.stopPropagation();
e.preventDefault();
alert("Hi");
});
})(document, Granite.$, Granite.author);
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
try the below code
$(document).on("dialog-ready", function(){
$("coral-multifield").children("button[coral-multifield-add]").on("click", function() {
//Logic
});
});
Views
Replies
Total Likes
Views
Replies
Total Likes