[tw5] How to make multiple "reveals" in one tiddler so that they work independently?

I can’t figure this one out. So, I have a sidebar search tiddler where I want to show three different kinds of searches at the same time but I want each of them to be collapsable for easy navigation. I got everything else working fine but I cannot figure out how to get them to collapse and expand independently.

The “reveal” widget combined with “qualify” seems to be used quite commonly, but in order for “qualify” to give independent values it has to be transcluded from somewhere else. This does not seem to work for me because if I transclude my list then it just breaks entirely. I think this is due to $(searchTiddler) not having a value outside of the tiddler or something.

Anyway, then I thought that I should be able to just ditch the “qualify” and use standard tiddlers as states? But the exact same issue happens.

So if I have something like

<$button class=“sidebar-collapsible” selectedClass=“sidebar-collapsible-onclick” popup=“test1”>
Title matches:
</$button>
<$reveal type=“match” state=“test1” text="">

</$reveal>

<$button class=“sidebar-collapsible” selectedClass=“sidebar-collapsible-onclick” popup=“test2”>
Title matches:
</$button>
<$reveal type=“match” state=“test2” text="">

</$reveal>

they do not work independently. I checked that the “test1” and “test2” are created and removed when I click the buttons but they cannot both be “on” at the same time (collapsed).

Can I get some help here? I feel like this should be a simple thing but it has taken me way too long already.

Thanks,
Petri

Popups are intended to appear only when the corresponding state tiddler has a value and the TWCore system automatically dismisses popups when it detects a click elsewhere.

However, your goal is to have an “anti-popup” that has the inverse behavior… i.e., it defaults to being visible unless the state tiddler value is set by a button click, and then remains that way until the button is clicked again. The solution is to not use popups at all. Instead, you want the button to simply toggle the state tiddler between blank and non-blank and then use that value to determine when to show the associated content.

Here’s one way to write this using set/setTo and a “filtered transclusion” to calculate the desired state value:

<$button class="sidebar-collapsible" selectedClass="sidebar-collapsible-onclick"
   set="test1" setTo={{{ [{test1}match[hide]then[show]else[hide]] }}}>Title matches:</$button>
<$reveal state="test1" type="nomatch" text="hide"> ... t1 </$reveal>

<$button class="sidebar-collapsible" selectedClass="sidebar-collapsible-onclick"
   set="test2" setTo={{{ [{test2}match[hide]then[show]else[hide]] }}}>Title matches:</$button>
<$reveal state="test2" type="nomatch" text="hide"> ... t2 </$reveal>

Note: The current value of the state tiddlers will be retained when you save your file. However, if you want the state tiddlers to be reset when you save the file, name them starting with “$:/state/popup/”. By default, tiddlers with that prefix are not retained when the file is saved.

enjoy,
-e

1 Like

Oh my god THANK YOU this was driving me nuts. I read that the popups are dismissed on click but I thought that you need to click the popup itself to dismiss it and I just never realised that you really do not have to.

Just one question, if I understand correclty the setTo=… is just a filter that checks whether the value of test1 is “hide”, if it is, it outputs “show”, if not then it outputs “hide”. However, why do we need the triple braces around the filter?

BR,
Petri

If there were were simple quotes around the filter, then it would be treated as a literal text value. The triple braces indicate that the parameter is using a “filtered transclusion” (aka, “inline filter”) and needs to be processed to get it’s actual value.

Note that, when used in normal wikitext content, the results of a filtered transclusion can return multiple values that are treated as a list of links. However, when a filtered transclusion is used as parameter in a $widget, only the first item in the list is used as the parameter value.

To see the difference, put the following content into a tiddler at http://TiddlyWiki.com

{{{ [tag[HelloThere]] }}}

<$text text={{{ [tag[HelloThere]] }}}/>

-e

Ah I see now, thanks for the clarification!

-Petri