List widget item -> reveal

99 views
Skip to first unread message

DD

unread,
Jun 23, 2016, 5:13:41 PM6/23/16
to TiddlyWikiDev
Hi,

I'm starting to slowly get my head around the way TW5 uses lists, filters and widgets to accomplish what TWC would've needed a plugin for. Maybe someone could point me in the right direction to see how to get the content of a $reveal to depend on a $list item.

I'm using $list and $button to create buttons for tiddlers with a particular tag. I then want to have a popup for each button that would list tiddlers tagged with the title of the tiddler corresponding to that button. So, starting simply:

<$list filter="[tag[foo]sort[title]]">
<$button popup="$:/popstate"><<currentTiddler>></$button>
<$reveal type="popup" state="$:/popstate">
<div class="tc-drop-down">
<$link filter="[all[current]tagging[]]" />
</div>
</$reveal>
</$list>

...doesn't work, because each button's popup gets the same content (the content for the last button in the list). I understand WHY this happens - similar to why an item in a FOR loop in Javascript has to be assigned as a property of a button in order to be accessed once the script is done. But I can't figure out how to use the TW5 tool set to accomplish this. I tried wrapping the buttons and reveal in a $set that defines the result of [all[current]tagging[]] as a variable, but that also does not work. Could someone show me how this would be done, or point me to a relevant example?

Thanks much! --Des

Jeremy Ruston

unread,
Jul 1, 2016, 5:32:32 AM7/1/16
to tiddly...@googlegroups.com
Hi DD

<$list filter="[tag[foo]sort[title]]">
<$button popup="$:/popstate"><<currentTiddler>></$button>
<$reveal type="popup" state="$:/popstate">
<div class="tc-drop-down">
<$link filter="[all[current]tagging[]]" />
</div>
</$reveal>
</$list>

I think there’s two issues here:

* The <$link> widget doesn’t take a “filter” attribute; the “to” attribute is used to specify a single tiddler to link to. In this case you could use the list-links macro: 

<<list-links "[all[current]tagging[]]">>

* You’re using the same state tiddler for all the buttons/reveals; this means that they are ganged together, and clicking any of the buttons opens all the reveal widgets. The solution is to use the qualify macro to generate a unique state tiddler name for each popup. To do that we have to move the body of the list widget into a separate template tiddler, eg called “ListEntryTemplate”:

<$button popup=<<qualify "$:/state/mytagchooser">>><<currentTiddler>></$button>
<$reveal type="popup" state=<<qualify "$:/state/mytagchooser">>>
<div class="tc-drop-down">
<<list-links "[all[current]tagging[]]">>
</div>
</$reveal>

Then you’d invoke it with the following:

<$list filter="[tag[Learning]sort[title]]" template="ListEntryTemplate”/>

Best wishes

Jeremy



...doesn't work, because each button's popup gets the same content (the content for the last button in the list). I understand WHY this happens - similar to why an item in a FOR loop in Javascript has to be assigned as a property of a button in order to be accessed once the script is done. But I can't figure out how to use the TW5 tool set to accomplish this. I tried wrapping the buttons and reveal in a $set that defines the result of [all[current]tagging[]] as a variable, but that also does not work. Could someone show me how this would be done, or point me to a relevant example?

Thanks much! --Des

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/bc7136c6-3aa0-48e3-b33b-494b0a8d178b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

DD

unread,
Jul 6, 2016, 4:51:57 PM7/6/16
to TiddlyWikiDev

The solution is to use the qualify macro to generate a unique state tiddler name for each popup. To do that we have to move the body of the list widget into a separate template tiddler, eg called “ListEntryTemplate”:


Wow, thanks. I learned a lot about state, qualify and templates in TW5 from this! --Des
Reply all
Reply to author
Forward
0 new messages