Confusion about using the new tiddler just after ActionCreateTiddlerWidget

Hi,

I would like to have something like this: when checked, a checkbox adds a tag to a tiddler but also creates a new tiddler based on the first one, without the possibly new tag.

I tried this on the TW site:

\define myactions()
    <$action-createtiddler $basetitle=<<currentTiddler>> $template=<<currentTiddler>> />
   <$action-listops $tiddler=<<createTiddler-title>> $field="tags" $subfilter="-done"/>
\end

<$tiddler tiddler="ActionCreateTiddlerWidget">
    <$checkbox tag="done" actions=<<myactions>>>
      done
    </$checkbox>
</$tiddler>

Apparently this causes the opposite result: the original tiddler does not get the new tag but the new tiddler has it.

I don’t really understand how the <<createTiddler-title>> is supposed to work (see official example).

What am I doing wrong?

I can’t answer that but, optionally, you can do this with a ButtonWidget instead. In a button you can control the order of events by using internal action widgets and the action attribute of the buttonwidget itself:

<$button actions=... >
<actionwidgets>
</$button>

I can’t remember right now which actions take place first (…I think it is first the inner ones and last the outer one, but not sure) but it would be simple to test.

1 Like

The createTiddler-title variable is only defined inside the scope of the $action-createtiddler widget. However, note that your use of the $action-createtiddler widget ends with a “/>”, which means that it has no content, and the $action-listops widget that follows it is outside the scope of the $action-createtiddler widget.

To use createTiddler-title properly, you need to write something like:

\define myactions()
   <$action-createtiddler $basetitle=<<currentTiddler>> $template=<<currentTiddler>>>
      <$action-listops $tiddler=<<createTiddler-title>> $field="tags" $subfilter="-done"/>
   </$action-createtiddler>
\end
3 Likes

Ok, this makes sense of course… silly me :sweat_smile:

Thank you Eric!

  • This action is doing what you ask, you are setting the tags field on the new tiddler with “-done”.
  • Perhaps change $tiddler to <<currentTiddler>> to reference the original tiddler.
  • Why are you using “-done”, do you want to remove the done tag?
1 Like

In the OP, @erwan uses a $checkbox to SET the done tag on the current tiddler. Then, as a side-effect, actions=<<myactions>> is invoked to COPY the current tiddler to a new tiddler, using the current tiddler as the $basetitle AND the $template, which results in the new tiddler having a tag of “done”, which is NOT wanted on the new tiddler. Thus, <<myactions>> also uses

<$action-listops $tiddler=<<createTiddler-title>> $field="tags" $subfilter="-done"/>

to remove the unwanted “done” tag.

Note: $action-listops has special-case handling for a $tags=... parameter, so this could also be written more compactly as

<$action-listops $tiddler=<<createTiddler-title>> $tags="-done"/>
2 Likes