Hi team,
I’m following the documentation and it’s very clear there is a event listener add-record-hrid but it never triggers at least with my table blocks. I want to stop the Add record modal to submit and send that information to make.com for validations and stuff but it’s not working.
<script>
window.addEventListener("block-loaded-list1", () => {
window.addEventListener("add-record-list1", (e) => {
console.log("adding the record -> ", e);
});
window.addEventListener("add-record-success-list1", (e) => {
console.log("success -> ", e);
});
window.addEventListener("add-record-failure-list1", (e) => {
console.log("failure -> ", e);
});
});
</script>
I’ve made a couple of test with the next script to check to event listeners triggering but as I said add-record-hrid has never triggered.
(function() {
const origAddEvent = document.addEventListener;
document.addEventListener = function(type, listener, options) {
console.log("Escuchando evento:", type);
return origAddEvent.call(this, type, listener, options);
};
const origDispatch = EventTarget.prototype.dispatchEvent;
EventTarget.prototype.dispatchEvent = function(event) {
if (event instanceof CustomEvent) {
console.log("CustomEvent disparado:", event.type, event.detail);
}
return origDispatch.call(this, event);
};
})();
I know the ID I’m using is fine because I can use add-record-success-hrid but add-record-hriddo not exists or is never triggering.
Am I doing something wrong? This is my actual code on my custom
<script>
window.addEventListener("block-loaded-table1", () => {
// This not works
window.addEventListener("add-record-table1", (e) => {
console.log('form submit', e.detail);
});
// This works
window.addEventListener("add-record-success-table1", (e) => {
console.log("adding the record -> ", e);
});
});
(function() {
const origAddEvent = document.addEventListener;
document.addEventListener = function(type, listener, options) {
console.log("Escuchando evento:", type);
return origAddEvent.call(this, type, listener, options);
};
const origDispatch = EventTarget.prototype.dispatchEvent;
EventTarget.prototype.dispatchEvent = function(event) {
if (event instanceof CustomEvent) {
console.log("CustomEvent disparado:", event.type, event.detail);
}
return origDispatch.call(this, event);
};
})();
</script>