tags: $:/tags/EditToolbar
title: Save & close button
<$fieldmangler><$button tooltip={{$:/language/Buttons/Save/Hint}} aria-label={{$:/language/Buttons/Save/Caption}} class=<<tv-config-toolbar-class>>>
<$action-sendmessage $message="tm-add-tag" $param={{$:/temp/NewTagName}}/>
<$action-deletetiddler $tiddler="$:/temp/NewTagName"/>
<$action-sendmessage $message="tm-add-field" $name={{$:/temp/newfieldname}} $value={{$:/temp/newfieldvalue}}/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<$action-sendmessage $message="tm-save-tiddler"/>
<$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/done-button}}{{$:/core/images/close-button}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/Save/Caption}}/></span>
</$list>
</$button>
</$fieldmangler>
I just double-checked it in a fresh empty TW. Sorry, its not closing the Tiddler.
<$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
<$action-sendmessage $message="tm-close-tiddler" $param={{!!draft.title}}/>
<$set name="ogtiddler" value={{!!draft.of}}>
<$fieldmangler><$button tooltip={{$:/language/Buttons/Save/Hint}} aria-label={{$:/language/Buttons/Save/Caption}} class=<<tv-config-toolbar-class>>>
<$action-sendmessage $message="tm-add-tag" $param={{$:/temp/NewTagName}}/>
<$action-deletetiddler $tiddler="$:/temp/NewTagName"/>
<$action-sendmessage $message="tm-add-field" $name={{$:/temp/newfieldname}} $value={{$:/temp/newfieldvalue}}/>
<$action-deletetiddler $tiddler="$:/temp/newfieldname"/>
<$action-deletetiddler $tiddler="$:/temp/newfieldvalue"/>
<$action-sendmessage $message="tm-save-tiddler"/>
<$action-sendmessage $message="tm-close-tiddler" $param=<<ogtiddler>>/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
OK
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/Save/Caption}}/></span>
</$list>
</$button>
</$fieldmangler>
</$set>
This seems to work ...
<$action-sendmessage $message="tm-close-tiddler" $param=<<currentTiddler>>/>
<$action-sendmessage $message="tm-save-tiddler"/>
<$set name="ogtiddler" value={{!!draft.of}}>
$param=<<ogtiddler>>
{{!!title}}
{{!!draft.of}}
{{!!draft.title}}
@Julian
Create a tiddler which contains:
{{!!title}}
{{!!draft.of}}
{{!!draft.title}}
In edit mode with preview mode enabled you see that `{{!!draft.of}}` and `{{!!draft.title}}` behave the same.
But - still in edit mode - change the title of that tiddler. Only `{{!!draft.title}}` follows the change! Why?
On Monday, May 29, 2017 at 12:08:13 PM UTC+2, Ton Gerner wrote:@Julian
Create a tiddler which contains:
{{!!title}}
{{!!draft.of}}
{{!!draft.title}}
In edit mode with preview mode enabled you see that `{{!!draft.of}}` and `{{!!draft.title}}` behave the same.
But - still in edit mode - change the title of that tiddler. Only `{{!!draft.title}}` follows the change! Why?That is exactly what I meant. draft.of contains the original title of the tiddler that is being edited; i.e. the name the tiddler had when you click the edit button, even if you change the title during editing. draft.title contains the title that the tiddler should get after editing. When you just pressed the edit button, this coincides with draft.of, because you haven't changed the title yet, but when you do, draft.title updates.
Now I am not that familiar with TiddlyWikis editing lifecycle internals, yet, but I presume that both are needed at the moment you save the tiddler.
You want to be able to reference the original tiddler, for example to potentially delete it when you changed the title,
or to write the new values of the draft tiddler back to it if you didn't.
Also, if you changed the title, you of course need to be able to reference that, to actually create the new tiddler.