th-closing-tiddler hook when tiddlers are closed 5.2.0 #5898
Replies: 3 comments 3 replies
-
There is a |
Beta Was this translation helpful? Give feedback.
-
I think @AnthonyMuscio is asking for a hook that is accessible to wikitext authors. It's something I've been thinking about, and your use cases are great examples. |
Beta Was this translation helpful? Give feedback.
-
Invoking actions via hooks is how I go about things where possible and part of the appeal is being able to re-use code and logic I have already written for use elsewhere as wikitext. This is indeed my use case for which I made the PR for the The general pattern I follow is shown below. We probably want to consider a similar pattern as part of a concerted effort to open up the navigation mechanism and logic to wikitext. I have never made a PR core support for invoking actions in hooks, as I feel it needs to be implemented as part of a navigation/navigator widget overhaul to ensure consistency and to not introduce further backwards compatibility restraints for that eventual refactoring. $tw.hooks.addHook("th-deleting-tiddler",function(tiddler) {
if(tiddler.fields["draft.of"]) {
return;
}
$tw.rootWidget.invokeActionsByTag("$:/tags/deleteTiddlerAction",null,{currentTiddler : tiddler.fields.title});
}); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Folks,
I have long sought the ability to set actions to occur on close of a tiddler, with the tiddler name available.
If this new hook makes this possible, could we have a way to trigger actions on close. It would assist with a whole suite of issues where we want post processing to occur on a tiddler. An example may be to stop a timer when the tiddler is closed to do time tracking, the other may be to take a snapshot of the tiddler as rendered on closing, so on return you see the snapshot until you refresh (helping very large computed tiddlers).
Something similar for open or navigate to a named tiddler would also be useful, but I have found some hacks to achieve this already, the idea would be to trigger pre-processing for a tiddler, the main case may be to start a timer but others will no doubt be useful.
Post script I already have a nice shapshot tool I just cant get it to action on close. There are already good timers, just they all need manual triggers (a click).
Regards
Tony
Beta Was this translation helpful? Give feedback.
All reactions