Can't get 'tm-save-wiki' to work

68 views
Skip to first unread message

Souf K

unread,
Jun 26, 2020, 3:47:48 AM6/26/20
to TiddlyWikiDev
Hello everyone!
I'm trying to fix the 'Save wiki' that is bundled with Command Palette (https://github.com/souk21/TW-commandpalette).
For the moment, it shows the notification "Saved wiki", but nothing else append. (no download, no error as well)

The first thing I tried was to check how `$:/core/ui/Buttons/save-wiki` is implemented.
I ended up with this:

<$wikify name="site-title" text={{$:/config/SaveWikiButton/Filename}}>
<$action-sendmessage $message="tm-save-wiki" $param={{$:/config/SaveWikiButton/Template}} filename=<<site-title>>/>
</$wikify>

Which works, as if I save it as a tiddler, it actually asks me to download the wiki.

But if I try to invoke it using JS `invokeActionString()` it only shows the notification and doesn't prompt for download.

Is there an inherent difference between executing tiddlytext in a tiddler or invoking it from JS?

I also tried sending the message directly from JS `$tw.rootWidget.dispatchEvent('tm-save-wiki')`

I tried to fiddle a bit with parameters, but the doc says its two parameters are optional, so I guess the problem is somewhere else.

If anyone can shine some light on this issue, I'll be grateful.

Thanks!
Souk21

Saq Imtiaz

unread,
Jun 26, 2020, 5:08:31 AM6/26/20
to TiddlyWikiDev
From what I can see of your code at a quick glance, you are using widget.dispatchEvent rather than invokeAction. Furthermore there are no parameters on the event.

I am pretty sure you need to specify param (the template to be used for saving). It is not optional, see https://tiddlywiki.com/#WidgetMessage%3A%20tm-save-wiki

You can see here how the tm-save-wiki message is handled:


Add the necessary parameters to the message and it should be handled correctly.

Souf K

unread,
Jun 28, 2020, 3:58:20 AM6/28/20
to TiddlyWikiDev
Thanks for your quick answer :)

I can get it to work from my browser's Web Console with both:

$tw.rootWidget.dispatchEvent({
    type: 'tm-save-wiki',
});

and

$tw.rootWidget.invokeActionString(`<$wikify name="site-title" text={{$:/config/SaveWikiButton/Filename}}>

<$action-sendmessage $message="tm-save-wiki" $param={{$:/config/SaveWikiButton/Template}} filename=<<site-title>>/>
</$wikify>`)


Unfortunately, for some reason,I doesn't work when called from my code.
I'm at a loss here...

Saq Imtiaz

unread,
Jun 28, 2020, 5:12:01 AM6/28/20
to TiddlyWikiDev
Without a demo with the updated code you are mentioning, I can only guess.

The download saver involves a click event at some point to trigger the download. Is your widget adding a click listener to the body/document that might be interfering?

Souf K

unread,
Jun 29, 2020, 3:51:55 AM6/29/20
to tiddly...@googlegroups.com
The download saver involves a click event at some point to trigger the download. Is your widget adding a click listener to the body/document that might be interfering?

Thanks !! That was it :) 

I can only guess.
 
That was a pretty good guess haha
More seriously, I'll definitely try to be more precise with my questions in the future.


Many many thanks for your time :)

Saq Imtiaz

unread,
Jun 29, 2020, 4:11:44 AM6/29/20
to TiddlyWikiDev
You're welcome. Don't hesitate to post if you have other questions in the future. 

If the issue is with code different from what is in the repo on github, just post a demo to make it easier to debug.
Reply all
Reply to author
Forward
0 new messages