How do I cause an update to the user interface from a trigger in the AFTER SAVE phase?

43 views
Skip to first unread message

Keith G

unread,
Oct 21, 2026, 12:29:43 PMOct 21
to mementodatabase
I have several JavaScript triggers that change the look of entries in the list view. Specifically, my scripts change fields that are set to appear in the 'Entry description' and 'Entry status'. They also change the background color of the entry as it appears in the list view using a Color field that is linked to the background color using the 'Entry background color' in the main tab of 'Edit library' screen.

My JavaScript triggers work fine when I set them to run in the BEFORE SAVE phase, but deep triggers are computationally intense because they need to calculate a lot of stuff, so they hold up the interface. But when I changed them to run in the AFTER SAVE phase, the user interface doesn't update until I do something else like cause another trigger to run. I have checked that my scripts are updating the fields as expected, it's simply that the updating of the fields does not trigger the expected change in the user interface.

How do I fix this?

Note that I am not using the ui() API. I am purely updating fields in the entries in my database. Note also that I'm using the Android app. 

Thanks.

David Gilmore

unread,
Oct 22, 2026, 11:08:30 AMOct 22
to mementodatabase
I assume you are aware of the entry's "recalc" method?  It can be useful when changes are made to certain fields in an entry. Javascript fields and other calculations will be redone.

I am not the developer, but I do know that suddenly modifying a view for no apparent reason, while the user is currently staring at it, can be disconcerting to the user. So Memento needs to be cautious of when views are refreshed. Memento, in a recent version, did change list views to refresh when certain specific fields are updated in the background. A good fix, but I did have to change some of my logic to compensate for it.

It also will be useful to know what type of fields are being updated in your "after save" function.
Reply all
Reply to author
Forward
0 new messages