I have written a tutorial on this topic:
https://appgini.bizzworxx.de/appgini-he ... box-click/
This is the result:
This is the code you will need:
Code: Select all
// file: hooks/TABLENAME-dv.js
var fieldname = "int_checkbox";
var alert_message = "This is my custom message for the warning";
var alert_variation = Variation.Warning;
new AppGiniField(fieldname)
.onChange(toggleAlert)
.insertAfter().alert(alert_message, alert_variation, "alert-on-check hidden");
new AppGiniDetailView().ready(toggleAlertAfterLoad);
function toggleAlertAfterLoad() {
// UPDATED 2020/03/03 JSE
$j("#" + fieldname).closest(".checkbox").next().addClass("alert-on-check");
var is_checked = $j("#" + fieldname).attr("checked") !== undefined;
toggleAlert(is_checked);
}
function toggleAlert(visible = true, className = "alert-on-check") {
var alert = jQuery("." + className);
if (!alert.length)
console.error("Alert not found: ." + className);
else {
if (visible) {
alert.removeClass("hidden");
} else {
alert.addClass("hidden");
}
}
}
https://appgini.bizzworxx.de/products/j ... -elements/
I hope you like it and it will help you!
Best,
Jan