For example: .cq-dialog-submit can be used to perform some operations before submitting the dialog in AEM 6.3 touchUI
listeners.js:
(function ($, $document) {
"use strict";
$document.on("dialog-ready", function() {
$(window).adaptTo("foundation-ui").alert("Open", "Dialog now open, event [dialog-ready]");
});
$(document).on("click", ".cq-dialog-submit", function (e) {
//$(window).adaptTo("foundation-ui").alert("Close", "Dialog closed, selector [.cq-dialog-submit]");
});
$document.on("dialog-ready", function() {
document.querySelector('form.cq-dialog').addEventListener('submit', function(){
//$(window).adaptTo("foundation-ui").alert("Close", "Dialog closed, selector [form.cq-dialog]");
}, true);
});
$document.on("dialog-success", function() {
//$(window).adaptTo("foundation-ui").alert("Save", "Dialog content saved, event [dialog-success]");
});
$document.on("dialog-closed", function() {
$(window).adaptTo("foundation-ui").alert("Close", "Dialog closed, event [dialog-closed]");
});
})($, $(document));
A simple scenario:
(function(document, $, ns) {
"use strict";
$(document).on("click", ".cq-dialog-submit", function(e) {
var $formminmax = $(this).closest("form.foundation-form");
var idSelector = $formminmax.find("[name='./idSelector']").val(); // This will contain the textfield data having name property as idSelector.
var field = $formminmax.find("[data-granite-coral-multifield-name='./prodId']");
var totalLinkCount = field.children('coral-multifield-item').length;
var prodData = []; //This will store the multifield data from the dialog.
for (var i = 0; i < totalLinkCount; i++) {
prodData.push(field.find($("[name='./productid']")[i]).val());
}
});
})(document, Granite.$, Granite.author);
});
$document.on("dialog-success", function() {
//$(window).adaptTo("foundation-ui").alert("Save", "Dialog content saved, event [dialog-success]");
});
$document.on("dialog-closed", function() {
$(window).adaptTo("foundation-ui").alert("Close", "Dialog closed, event [dialog-closed]");
});
})($, $(document));
A simple scenario:
(function(document, $, ns) {
"use strict";
$(document).on("click", ".cq-dialog-submit", function(e) {
var $formminmax = $(this).closest("form.foundation-form");
var idSelector = $formminmax.find("[name='./idSelector']").val(); // This will contain the textfield data having name property as idSelector.
var field = $formminmax.find("[data-granite-coral-multifield-name='./prodId']");
var totalLinkCount = field.children('coral-multifield-item').length;
var prodData = []; //This will store the multifield data from the dialog.
for (var i = 0; i < totalLinkCount; i++) {
prodData.push(field.find($("[name='./productid']")[i]).val());
}
});
})(document, Granite.$, Granite.author);
No comments:
Post a Comment
If you have any doubts or questions, please let us know.