ricky
March 27, 2023, 5:26pm
1
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
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
moosh
March 27, 2023, 6:26pm
4
Thanks, this works much faster. And the same with filters if all tiddlers are labeled
Surge
May 23, 2023, 3:56am
5
@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
Surge
May 23, 2023, 3:01pm
7
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.
Surge
May 23, 2023, 6:32pm
8
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.