I am trying to invoke a procedure from a button widget but the invoked procedure does not have any action widgets.
Basically, we only want to initiate a backlinks display when the user clicks the button. That way we don’t waste computer resources displaying something not required.
Code:
ViewTemplate
<$list filter="[<currentTiddler>tag[Gun Type]]" >
<$button actions=<<TLSbacklinks>> >
Click to see backlinks
</$button>
</$list>
Procedure code
<!-- EXTRACTS BACKLINKS FROM THE CURRENT TIDDLER -->
\procedure TLSbacklinks()
<$list filter="[all[current]backlinks[]]" counter="numberofbacklinks" emptyMessage="There are no links to this record" >
<% if [<numberofbacklinks-first>match[yes]] %>
This record is linked from the following:
<br>
<% endif %>
<<TLSdisplaylinks>>
</$list>
\end
Use the $button to set a $:/temp tiddler to “yes”, and then use that $:/temp tiddler’s value to control when to show the output.
Like this:
<$let temp=<<qualify "$:/temp/showbacklinks">>>
<$list filter="[<currentTiddler>tag[Gun Type]]">
<$button set=<<temp>> setTo="yes">Click to see backlinks</$button>
<%if [<temp>text[yes]] %><<TLSbacklinks>><%endif%>
</$list>
</$let>
Note that <<qualify "$:/temp/showbacklinks">> will create a separate $:/temp tiddler for each tiddler in which it is used so each tiddler’s backlinks display can be controlled independently.
Bugger, I was on the right track. I just couldn’t see how to trigger the procedure once the temp tiddler was set to Yes. Didn’t know about the qualify macro.
@TW_Tones , I seem to remember reading something a while ago hat $ reveal was being deprecated and being replaced by %if. Then sometime later, @pmario commented on a post that that was wrong.
even if it were deprecated you can possibly still use it for a decade, however it does not really have a replacement yet as it includes animation that nothing else does.
you can do the same with a list and if statements. you could even extract the if I put inside the button.
We can not deprecate reveal yet, since we can not fully replicate its functionality yet. eg: popups, animation and so on.
Many places in the current UI can be replaced by the conditional %if statement, which gives a cleaner more semantic DOM structure.
The main problem with reveal was, that is often was used as an if, but it creates a DOM element, that is basically just “overhead” if the reveal is in “closed” state. – And we have many of them, which also make custom styling more difficult. That’s one reason, why we want to reduce them.