How to close a tiddler in the story from within a modal?

If the title isn’t clear, my problem is best illustrated with a simple example. Here is a demo wiki for the example below.

I have a Modal tiddler with the below content. I can open the HelloThere tiddler and close it with the button.

[[HelloThere]]

<$button>
Close HelloThere
<$action-sendmessage $message="tm-close-tiddler" $param="HelloThere"/>
</$button>

I also have an OpenModal tiddler can be used to open Modal in a modal window:

<$button>
Open modal
<$action-sendmessage $message="tm-modal" $param="Modal" />
</$button>

But if I press the Close HelloThere button from within the modal window, HelloThere remains in the story river.

Is there a way to press a button and close both the modal window, and the HelloThere tiddler at the same time?

Normally, the tm-close-tiddler message is handled by a <$navigator> widget that encloses the Story River.

However, when displayed inside a modal, the tm-close-tiddler is outside of the Story River. Thus, there is no <$navigator> widget to process the message.

To fix this, just add this line at the start of your modal content:

<$navigator story="$:/StoryList" history="$:/HistoryList">

See https://tiddlywiki.com/#NavigatorWidget for more info.

edit:
To close BOTH the modal window AND the HelloThere tiddler at the same time, you need to put the <$navigator> widget around ONLY the <$action-sendmessage $message="tm-close-tiddler" ...>, like this:

[[HelloThere]]

<$button message="tm-close-tiddler">
Close HelloThere
<$navigator story="$:/StoryList" history="$:/HistoryList">
<$action-sendmessage $message="tm-close-tiddler" $param="HelloThere"/>
</$navigator>
</$button>

By doing this, the message on the $button widget closes the modal window itself, while the $action-sendmessage acts on the Story River to close the “HelloThere” tiddler

enjoy,
-e

5 Likes

Thank you yet again :slight_smile: