I have made a button that creates 3 tiddlers. The names of these tiddlers are made with the unusedtitle Macro with a given base, separator and count value (template). It works pretty good.
But
I can only make one new group of tiddlers with a correct name.
After that, clicking the button results in a new group of tiddlers but now with the same name and 00 (incl. space character) placed at the end of the name.
Clicking again results in the same name with 01, 02, etc.
The only way to get correct results is to explicitly save the wiki and refresh the browser. Clicking the browser after those actions gives a good result.
Does anyone know why this is ?
And, more importantly, how to change this behavior.
Browser is Vivaldi latest Tiddlywiki 5.2.3 latest OS is windows 10 timimi for saving
My Guess is the new name is being determined when the button is rendered rather than calculated when the button in clicked. If you move your actions into a macro and invoke them with actions=<<macroname>> on the button it may fix it. Remember the button may have “shortcut” parameters on it like setField but all these can also be done with actions like actionsetfield and actioncreatetiddler.
@TW_Tones I understand what you mean but I don’t know what to do about the part that is now wikified. Any suggestions?
Code
I have never used the LetWidget, unusedTitle Macro and ActionCreateTiddlerWidget before. I want to try those because it seems more convenient than my own solutions.
So thank you for your patience.
I have 3 tiddlers for the code.
auto-btn-multi for the actual button
macro-tabs for the macro’s e.g. unusedTitle Macro
button-main-menu to put the above together and showing the button
Then reference this in the button <$button class=<<class>> tooltip=<<tooltip>> actions=<<tri-tiddler-create-actions>> >
Removing the actions from inside the button.
I understood from others that this was the way to have the actions “refreshed on click”. I am confident but not certain of this.
By the way - when you provide a $basetitle the resulting tiddler is effectively generated as an unused title. Within the Create tiddler widget you use <<createTiddler-title>> to retrieve the resulting tiddler title with its increment if relevant eg ‘New Tiddler 2’, if “New Tiddler” and “New Tiddler 1” already exist.
So Construct the New titles “base title” in the Create tiddler widget and no need to use the untitled macro.
The 2nd and 3rd tiddler are now used as tabs for the 1st created tiddler. That’s why I am tagging them with the title of the first.
like this: new-tag-1=<<new-name>> and new-tag-2=<<new-name>>
where <<new-name>> is the title of the first tiddler.
However I would also like to add an additional tag to those “tab tiddlers” e.g. extra-tag. But I don’t know how to do this.
The problem being that a macro outside of the button doesn’t refresh on consecutive runs.
Any ideas how to construct adding 2 tags to the “tab tiddlers” ?
I am using the unusedTitle Macro because it gives the ability for templating the title. I don’t know if/how that can be done with the $basetitle in the ActionCreateTiddlerWidget.
In the current situation the macro is used to supply the tiddler name as a variable in the let widget.
You must either set all tags at once with tags="tagname1 tagname2" inside the create new tiddler parameters
One trick here is using a filtered transclusion tags={{{ filter }}} where the filter results in the tags field, with its multiple tags.
or use one or more <$action-sendmessage $message=" tm-add-tag" $param="tagname"/>
Note your code needs to be wrapped in the <$fieldmangler> code </$fieldmangler> widget.
You can also use the ActionListopsWidget on any field including the tags field but that may be more complex than need be.
In the ActionCreateTiddlerWidget it will ensure its a unique name by adding a number at the end, just like the standard new tiddler button, however you can’t set the “count” field places to be zero filled. Of course you decide what the base title is so you can include a separator in it eg $basetitle="$name-suf$ - "
I’ve tried this solution already but the <$fieldmangler> needs to know the tiddler it will be operating on. Since I have 2 tiddlers I don’t know how to do that.
The $basetitle seems to always add in a space character. I 'd rather not have those in my titles. Hence my choice.
I totally forgot about this one. Excellent !
And once again, you’re continued help and support are immensely appreciated. Many thanks !