You can use <granite:data & listeners to trigger servlet.
as mentioned below, you can set the class or identifier to invoke method when content loads.
<granite:data
jcr:primaryType="nt:unstructured"
dd-showhide-target=".show-hide-field"/>
JS.
the foundation-contentloaded will be triggered whenever dialog opens
(function (document, $, Coral) {
"use strict";
$(document).on("foundation-contentloaded", function (e) {
$(".class", e.target).each(function (i, element) {
var target = $(element).data("data-fld-class");
if (target) {
Coral.commons.ready(element, function (component) {
// write you logic
}
});
})(document, Granite.$, Coral);
More details :
Listeners implementations in touch UI.
Adobe Experience Manager Help | Using Event Handlers in Adobe Experience Manager Touch UI Components
Thanks!