I am using a list where I want a close button for each item. How would be able to close the specified tiddler in the list.
Below is what I have tried, but it’s only closing <<currentTiddler>>:
<$list filter="my-filter" variable="my-list-item">
<$button tiddler=<<my-list-item>> message="tm-close-tiddler">
{{$:/core/images/close-button}}
</$button>
<$link to=<<my-list-item>>/>
</$list>
I have a macro I include after a list item, where each tiddler becomes currentTiddler
\define close-button()
<$button message="tm-close-tiddler" tooltip="Close - item open in story" aria-label={{$:/language/Buttons/Close/Caption}} class="tc-btn-invisible">x</$button>
\end
<$list filter="[tag[TableOfContents]]">
<$link/> <<close-button>><br>
</$list>
- This works and will close tiddlers If Open
However if your filter lists items also not open a condition so you test if it is open first befor displaying the close button makes sense.
I do this in this history sidebar. warning under redevelopment,
history-sidebar.json (2.8 KB)
You were almost there!
As documented here: https://tiddlywiki.com/#WidgetMessage%3A%20tm-close-tiddler, the tm-close-tiddler message uses param (not tiddler) to specify the title to be closed. Thus, your code should be:
<$list filter="my-filter" variable="my-list-item">
<$button message="tm-close-tiddler" param=<<my-list-item>>>
{{$:/core/images/close-button}}
</$button>
<$link to=<<my-list-item>>/>
</$list>
Alternatively, if you omit variable=my-list-item in the $list widget (i.e., allow it to use the default variable, currentTiddler), you can simplify it to just:
<$list filter="my-filter">
<$button message="tm-close-tiddler">
{{$:/core/images/close-button}}
</$button>
<$link/>
</$list>
Note that the above code uses the value of currentTiddler as the default parameter for the $link widget as well.
enjoy,
-e