How to trigger list after button click?

Hi

I use this code to search Tiddlers with title, and it works fine.

<$edit-text tiddler="txtKeyword" field="keyword"/>
<<list-links [search:title{txtKeyword!!keyword}] >>

The total number of my Tiddlers has reached 30,000. (in one file)

When typed charater will refresh list-link that freezes the browser 1-2 sec.

I want to add a button, the list-link filter will trigger after button click.

how to fix this code?

Add the field throttle.refresh to the tiddler txtKeyword.

See https://tiddlywiki.com/#RefreshThrottling

5 Likes

Here’s an approach that allows you to type as much as you want without triggering a search until the “find” button is pressed:

<$edit-text tiddler="$:/temp/txtKeyword" field="keyword"/>
<$button>find<$action-setfield $tiddler="txtKeyword" keyword={{$:/temp/txtKeyword!!keyword}}/></$button>
<<list-links [search:title{txtKeyword!!keyword}] >>
  • As you type, the input is stored in $:/temp/txtKeyword!!keyword
  • When you press the “find” button, the temp input is copied to the tiddler field (txtKeyword!!keyword) that is actually used for searching.

enjoy,
-e

3 Likes

Thanks, this works much faster. And the same with filters if all tiddlers are labeled1-2023-03-28_00.57.45

1 Like

@EricShulman This is very nice. Is it also possible to mimic the button press when I press enter?

To respond to the enter key, you can enclose the $edit-text widget within a $keyboard widget, like this:

\define go() <$action-setfield $tiddler="txtKeyword" keyword={{$:/temp/txtKeyword!!keyword}}/>

<$keyboard key="enter" actions=<<go>>>
   <$edit-text tiddler="$:/temp/txtKeyword" field="keyword"/>
</$keyboard>
<$button actions=<<go>>>find</$button>
<<list-links [search:title{txtKeyword!!keyword}] >>

Notes

  • Since you want the exact same actions to be performed via enter key or $button press, I put the $action-setfield within a macro (<<go>>).

enjoy,
-e

4 Likes

Hmm, it doesn’t seem to be working – the button is working but Enter is not. Any ideas? I’m on a Mac, maybe that’s the reason? I’ve tried ctrl+enter as well.

Ah, I figured it out. It wasn’t working because the keyboard widget needs to wrap the input field and I wrapped the button instead.