I have a modal 'edit/create task' (scoped globally) where I can add a task to a page 'project'. But I also have an overview of all tasks where I can also add a task (and link it to a project'). All this works fine!
But I can't seem to trigger the refresh of the tables when returning to the overview pages (task and project).
ChatGPT suggested working with a variable or state but I always run into a scope problem. From the modal, the local queries are out of scope and from the overview page, I can't see when the modal is closed.
I could refresh the query every few seconds but that just looks like a huge waste of resources.
You could try passing in a url parameter and if it exists and depending on what value you set you could have the table reload through an event on page load.... quick and dirty hack btw - I am sure there is more than likely a cleaner approach....
Hi Scott, I've put a confirmation message before running the JS and it only triggers the on page load event when loading the page, not when returning from a modal.
I did find a work-around and that is to add a globa) variable (here shouldRefreshTasks) to the query like:
where (t1.fk_project = {{ tbl_projects_main.selectedRow.id }}) or (1 = {{ shouldRefreshTasks.value }})
and in the advanced section of the query add "shouldRefreshTasks.value" as a watched input.
When I press the save button on the modal, I change the value with Math.random() * 1000 so the refresh is triggered because the watched value changed.
Not my original brainwave but I found it related to another question: watched inputs