[TW5] Close tiddler with JavaScript call

122 views
Skip to first unread message

Aigars Rogozovs

unread,
Sep 4, 2017, 6:34:38 AM9/4/17
to TiddlyWikiDev
Hello

How I can close TW5 tiddler via JavaScript if I known it name?

I`m writing 3rd party plugin

Thanks

A.

TonyM

unread,
Sep 5, 2017, 2:51:34 AM9/5/17
to TiddlyWikiDev
Aigars,

Not exactly answering your question but this discussion resulted in the sharing of the following "macros" that may be of use;

In this case the Button is used to trigger the action widget action-sendmessage. So a Question someone could answer is how to trigger action widgets from Javascript?.

Best of Luck
Tony

\define closeByFilter(filter)
filter: $filter$
<$button>
close filtered tiddlers
<$list filter=$filter$>
<$action-sendmessage $message="tm-close-tiddler"/>
</$list>
</$button>
\end

\define openByFilter(filter)
filter: $filter$
<$button>
open filtered tiddlers
<$list filter=$filter$>
<$action-navigate $to={{!!title}}/>
<$action-sendmessage $message="tm-unfold-all-tiddlers"/>
</$list>
</$button>
\end

Aigars Rogozovs

unread,
Sep 5, 2017, 3:10:33 AM9/5/17
to TiddlyWikiDev
Thanks for answer

Not Macros, but with JavaScript :)

This Macros I already used, but without result

For example:

function search_by_tag(tag_name) {
  $('.tc-tiddler-frame').each(function(tiddler_frame) {
    var self = this;
    var tags_label = $(self).find('.tc-tag-label');
    var tags = [];
    $(this).each(function(tag) {
      var tag_name = $(tag).text().trim();
      tags.push(tag_name);
    });
    console.log(tags);
  });
}

I find all tags

What result I want:

When user open tiddler, other tiddlers with same tags close automatically

I don't known how to make that with Macros, so I make it with jQuery

A.

BJ

unread,
Sep 5, 2017, 12:14:56 PM9/5/17
to TiddlyWikiDev
The concept in tw5 is of a tree build of js widgets (js macros are connect to the tree through the macrocall widget), you can send messages up the tree, eg

this.dispatchEvent({type: "tm-close-tiddler", tiddlerTitle: "mytid"})


sends a message to the navigator widget to close a tid.

all the best

BJ
Message has been deleted

Aigars Rogozovs

unread,
Sep 7, 2017, 6:44:26 AM9/7/17
to tiddly...@googlegroups.com
How I can access this tree?

$tw.wiki?

EDIT: Done, it`s work

A.
Reply all
Reply to author
Forward
0 new messages