[TW5] Button to create Tid 1, then Tid 2, Tid 3 etc, i.e numbered just like New Tiddler button does.

109 views
Skip to first unread message

Mat

unread,
May 21, 2015, 2:11:58 AM5/21/15
to tiddl...@googlegroups.com
The following is basically a "new tiddler" button but intended to use the default title specified as a prefix, for example the prefix Bookmark. 
What I want is that the first time it's used, it creates the tiddler titled Bookmark. (I save it with that title). The next time I click the button, it should therefore set the title to Bookmark 1 then Bookmark 2 etc. I.e just like for New Tiddler.

What happens instead is that the first created tiddler, Bookmark, is reopened for edit. How can I prevent this from happening? 


\define newBookmark(pfix="noprefix")
<$button tooltip={{$:/language/Buttons/NewHere/Hint}} aria-label={{$:/language/Buttons/NewHere/Caption}} class=<<tv-config-toolbar-class>>>
<$action-sendmessage $message="tm-new-tiddler" title="$pfix$"/>
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/new-here-button}}
</$list>
<$list filter="[<tv-config-toolbar-text>prefix[yes]]">
<span class="tc-btn-text"><$text text={{$:/language/Buttons/NewHere/Caption}}/></span>
</$list>
</$button>
\end


Thank you!

<:-) 

Eric Shulman

unread,
May 21, 2015, 3:18:08 AM5/21/15
to tiddl...@googlegroups.com
On Wednesday, May 20, 2015 at 11:11:58 PM UTC-7, Mat wrote:
The following is basically a "new tiddler" button but intended to use the default title specified as a prefix, for example the prefix Bookmark. 
What I want is that the first time it's used, it creates the tiddler titled Bookmark. (I save it with that title). The next time I click the button, it should therefore set the title to Bookmark 1 then Bookmark 2 etc. I.e just like for New Tiddler.
What happens instead is that the first created tiddler, Bookmark, is reopened for edit. How can I prevent this from happening? 

You were VERY close!

The problem is this line: 
<$action-sendmessage $message="tm-new-tiddler" title="$pfix$"/>

According to the documentation <$action-sendmessage $message="tm-new-tiddler" ...> only knows about three possible parameters names:

param
The optional title of a tiddler to use as a template for the new tiddler
paramObject
Optional hashmap of additional tiddler fields
navigateFromTitle
Title of the tiddler from which the navigation to the new tiddler was initiated

However, you used title="$pfix$".. and "title" is not a recognized param name for this message.

You need to use $param="$pfix$" instead.  If you make that one change, then the "auto numbering" will work as you expected.

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Eric Shulman

unread,
May 21, 2015, 3:28:53 AM5/21/15
to tiddl...@googlegroups.com

errata:

On Thursday, May 21, 2015 at 12:18:08 AM UTC-7, Eric Shulman wrote:
However, you used title="$pfix$".. and "title" is not a recognized param name for this message.

Actually, title="..." *is* recognized by the message handler (as evidenced by the fact that it *does* create a tiddler with that title).

However, auto-numbering is only applied when you use $param="..." value (or a title field within a JSON $paramObject="..." value).

All other param names (including title="...") are simply assigned to the tiddler when it is opened for editing.

Thus, by using title="..." the tm-new-tiddler handler first created a tiddler called "New Tiddler" (the default title, with autonumbering added as needed), and then immediately overwrote that value and assigned title="Bookmark" instead.  Had you used $param="Bookmark", the message handler would have just started with that title and applied the autonumbering as you wanted.

-e

Mat

unread,
May 21, 2015, 5:36:59 AM5/21/15
to tiddl...@googlegroups.com
Now it works! Great! Thank you Eric! :-D

FYI: It will be part of a "bookmarks presenter", i.e a table listing useful links. Your reply here will be included as one such ;-)

<:-)
Reply all
Reply to author
Forward
0 new messages