From 8db846ad5dc21aa23ff7fbd41e52b7cfe367b179 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 6 Jun 2025 16:37:55 +0530 Subject: [PATCH] fix: trigger onload method if controller is loaded --- frontend/src/data/document.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/data/document.js b/frontend/src/data/document.js index 8760ccbb..a38e8ed6 100644 --- a/frontend/src/data/document.js +++ b/frontend/src/data/document.js @@ -75,6 +75,8 @@ export function useDocument(doctype, docname) { organizedControllers[controllerKey].push(controller) } controllersCache[doctype][docname || ''] = organizedControllers + + triggerOnload() } function getControllers(row = null) { @@ -93,9 +95,16 @@ export function useDocument(doctype, docname) { return [] } + async function triggerOnload() { + const handler = async function () { + await this.onload?.() + } + await trigger(handler) + } + async function triggerOnRefresh() { const handler = async function () { - await this.refresh() + await this.refresh?.() } await trigger(handler) } @@ -189,6 +198,8 @@ export function useDocument(doctype, docname) { return { document: documentsCache[doctype][docname || ''], assignees, + getControllers, + triggerOnload, triggerOnChange, triggerOnRowAdd, triggerOnRowRemove,