Can I use navigator in a modal?

I tried jumping to a tiddler after closing the modal, which doesn’t seem to work

<$navigator story="$:/StoryList" history="$:/HistoryList">
<$button tooltip="tip">
  Jump xxx tiddler
  <$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
  <$action-navigate $to=<<currentTiddler>>/>
</$button>
</$navigator>

Here is chatgpt’s answer, which is obviously not entirely correct

If you use the TiddlyWiki code provided above in a modal box, you may run into problems because the modal box will run in the context of the current page, not in the context of the TiddlyWiki application.

In order to use the code in a modal box, you need to make sure that the code is running in the context of TiddlyWiki. You can implement the code as a custom widget for TiddlyWiki, and then call the custom widget in the modal box.

To create a custom widget, save the above code in a file called yourCustomWidgetName.tid and place the file in the $:/widgets/ directory of TiddlyWiki. Then call the custom component in your TiddlyWiki article using the following syntax.

bash
Copy code
<$yourCustomWidgetName/>
This way, when you use this syntax in a modal box, the code will work correctly in the context of the TiddlyWiki application.

Translated with www.DeepL.com/Translator (free version)

Have you tried it without the navigator? Just the nav action.

You can navigate first then close the modal.

Yes, it works, but after using startup action instead of the manual trigger modal, the nav no longer works, it just closes the modal

<!-- tags: $:/tags/StartupAction/PostRender -->
<$action-sendmessage $message="tm-modal" $param="modal-tiddler"/>
<!-- modal-tiddler -->
<$button> Jump xxx Tiddler
  <$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
  <$action-navigate $to=<<currentTiddler>>/>
</$button>

What is the value of <<currentTiddler>> when the $button is rendered?

To verify the value, try using:

<!-- modal-tiddler -->
<$button> Jump xxx Tiddler
<br>DEBUG: CURRENTTIDDLER=<<currentTiddler>><br>
  <$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
  <$action-navigate $to=<<currentTiddler>>/>
</$button>

I suspect that the value will be “modal-tiddler” instead of whatever tiddler title you wanted.

-e

You are right, I have tried this before, it seems that I was wrong before

Even if the currentTiddler is a fixed modal-tiddler, shouldn’t it be possible to close the current modal, and then navigate to this modal-tiddle?

<$action-navigate $to="modal-tiddler"/>

Dealing with Modals, I try to find a step in the process where I can write a tiddler title to a $:/temp/ tiddler. Then I can reference that title in later steps, inside or outside the modal. Most of the time, I create the temp tiddler when launching the initial modal.

You should be able to <$action-navigate $to={{$:/temp/…}} />from wherever you need to later on.

1 Like