Is there an option to have an input tag (e.g. text input), with a button "save" next to it which then saves to a tiddler field?

67 views
Skip to first unread message

Melvin

unread,
Aug 2, 2019, 8:13:17 AM8/2/19
to tiddl...@googlegroups.com
I am trying to find a suitable workaround for edit-text. I'm using TiddlyWiki as my journal.

I have a template Tiddly for questions with radio buttons and all that. I clone it for the day, change the date and that is my new Tiddler.

However, the amount of stuff I need to edit within my tiddler just to answer some questions is becoming a lot. I'd like to do it via input fields.

For example, I have questions such as: what goal do you have for today (up to a max of 3 goals).

Now I'd need to edit the Tiddler for it.

But I'd like to simply see an input tag with a button save next to it and when I type in my goal and click "save!" it replaces the text that was within the field.

In that sense it looks a lot like the appender of the following TiddlyWiki at http://skeeve.tiddlyspot.com/

Another example (but then with a dropdown menu instead of free input text) is http://inmysocks.tiddlyspot.com/#Concatenating%20Strings%20-%20What%20Breaks

Melvin

unread,
Aug 2, 2019, 8:45:56 AM8/2/19
to TiddlyWiki
I got it by doing

<$edit-text tiddler="StoreDailyQuestionnaireData" field="mytestfield"/>
<$button><$action-setfield $field=demonstration1 $value={{StoreDailyQuestionnaireData!!mytestfield}} />Set the field 1</$button>
<$button><$action-setfield $field=demonstration2 $value={{StoreDailyQuestionnaireData!!mytestfield}} />Set the field 2</$button>

---
<$view field=demonstration1/>
<br />
<$view field=demonstration2/>

Melvin

unread,
Aug 3, 2019, 5:04:02 AM8/3/19
to TiddlyWiki
My final working code is:

goal 1: <$view field=g1_value/> <$edit-text tiddler="StoreDailyQuestionnaireData" field="g1_value"/> 
<$button>
<$action-setfield $field=g1_value $value={{StoreDailyQuestionnaireData!!g1_value}} />
<$action-setfield $tiddler="StoreDailyQuestionnaireData" $field="g1_value" $value="" />
change goal 1
</$button> 

Mat

unread,
Aug 3, 2019, 6:12:57 AM8/3/19
to TiddlyWiki
Thanks for sharing Melvin.

Just a note; your use of the html term "input tag" risks causing confusion here because in TW "tag" is the visual tag pills seen in tiddlers. Just sayin'.

A thought: Do you necessarily want to apply the text using a button or wouldn't it be more convenient if the text was simply applied as you type it? You can do this by this construct;

<$vars curr=<<currentTiddler>>>
<$tiddler tiddler=dummy>
<$edittext tiddler=<<curr>> field="thefieldyouwant" />
</$tiddler>
</$vars>


<:-)

Melvin

unread,
Aug 3, 2019, 6:44:06 AM8/3/19
to tiddl...@googlegroups.com
Thanks! I'll try it out. On thinking about it though (if I understand it correctly), that also means that this will be displayed in all my other edittext tags, even in other journal entries. That means this might make it more error prone if I accidentally select another eddittext tag from another journal entry, since I'll be overwriting the data.

I'm not that deep into 'TiddlyWiki programming' yet.

In fact, I just modified my TW to turn the <script> tag back on to make hacking TW a bit easier, because I'll be simply using it locally on my laptop anyways.

Mat

unread,
Aug 3, 2019, 8:35:30 AM8/3/19
to TiddlyWiki
Melvin wrote:
Thanks! I'll try it out. On thinking about it though (if I understand it correctly), that also means that this will be displayed in all my other edittext tags, even in other journal entries. That means this might make it more error prone if I accidentally select another eddittext tag from another journal entry, since I'll be overwriting the data.

It almost sounds as if you're modifying the actual edittext widget itself??? 

Exactly where do you put your code? What is the name of the tiddler and how is this tiddler tag(-pilled) ?
 

I'm not that deep into 'TiddlyWiki programming' yet.

In fact, I just modified my TW to turn the <script> tag back on to make hacking TW a bit easier, because I'll be simply using it locally on my laptop anyways.

I am deep into TW programming - in the pure wikitext sense. You seem to do js stuff, of which I know nothing - but IMO you should not mess around with the js in TW if you're not familiar with TW as it is supposed to work first. I suspect there are many pits to fall into. What you are requesting in the OP is probably exactly what TW is designed to allow to hack with absolutely no js. For js questions, the Dev group is the place.

<:-)

TonyM

unread,
Aug 3, 2019, 10:45:06 PM8/3/19
to TiddlyWiki
Melvin,

I know you have walked down a different path but I suggest making a tiddler tagged $:/tags/ViewTemplate that transcludes a template tiddler (containing the edit text) on the tiddler where you require the edit to take place.

This allows you appear to be editing the current tiddler without the focus problem, but you are actually editing it from the template tiddler.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages