Is it possible to execute an action widget on tiddler load/render/open?

I want to be able to scroll to an element inside a <$scrollable> widget when I load/render/open the tiddler. I thought of using the <$action> widget like this:

<$button>
<$action-sendmessage $message="tm-scroll" $name="selector" $value={{!!tiddler-id}}/>
scroll to element
</$button>

Is there a way I can do this? Is there another way to activate $message="tm-scroll"?

I don’t think there exists a way to send a message on rendering a tiddler.

However you can create a js macro to do this. (look at $:/core/modules/macros/now.js to see an example macro).
the macro would be:


/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

/*
Information about this macro
*/

exports.name = "invoke";

exports.params = [
	{name: "action"}
];

/*
Run the macro
*/
exports.run = function(action) {
this.invokeActionString(action,this,{},{});
	return "";
};

})();

An example to show a message in the console is:

<$macrocall $name="invoke" action="""<$action-log $$message="hi this is an action"/>"""/>

I did create an experimental plugin that contains a “trigger” widget, which automatically triggers actions, when it is shown. …

Be careful. Functions like that have the potential to create “endless loops”, that can brick your wiki. So a BACKUP is recommended!

The info how to install my plugins can be found at: https://wikilabs.github.io and the plugin demo page can be found at: Trigger — an interactive test framework

I thought a plugin or a macro might do the trick. I am going to have to look at this when I have time.

I came across Wikilabs trying to find a plugin. I’ll take a look at it when I have time. Thanks.

Also ask yourself what leads to the “tiddler load/render/open” because if you provide the list that leads to opening a tiddler you can add an action their in to open on click. For example if you are using the TOC macro(s), you could build your own or modify an existing one.

Alternatively you may use the message catcher widget to wrap places where the links you navigate from and include your additional actions on tiddlers.

The trick with a community like ours is to put your best effort into sharable hacks than bespoke solutions, and the community helps and benefits.

I finally had time to play around with this, and I got this <$trigger> macro to work. I figured a plugin like this would work. I am not having any issues with endless loops for now at least. I wasn’t worried about losing anything, all my data is still on TWC. Thanks for the help!

If you are careful and if you have no typos in your variable names, everything should be fine. …

But I do write a warning, because there is a possibility to “brick” your wiki. … It doesn’t “destroy” itself, like in the movies :wink: but it is possible to make the UI unresponsive. …

TiddlyWiki has a “safe mode”. See: https://tiddlywiki.com/#SafeMode, with which you can start it, with all plugins deactivated. In most cases this is enough to “disable” plugins that “go rogue”. … Just to be sure.

have fun!
mario