[TW5] addEventListener to links

99 views
Skip to first unread message

Aigars Rogozovs

unread,
Sep 13, 2017, 5:40:07 AM9/13/17
to TiddlyWikiDev

Hello

I try to add to link tags listener:

$('body').on('click', 'a', function(e){
  console
.dir(e);
});

But nothing happens

How I can add event listening to links?

A.

BJ

unread,
Sep 13, 2017, 11:04:33 AM9/13/17
to TiddlyWikiDev
tiddlywiki uses a dynamic tree of widgets you need to understand how this work in order to use javascript, see here for how to use the link widget with wikitext

http://tiddlywiki.com/#LinkWidget

all the best
BJ

BJ

unread,
Sep 13, 2017, 11:06:48 AM9/13/17
to TiddlyWikiDev

see here for info on tiddlywiki internals

http://tiddlywiki.com/dev/#TiddlyWiki%20for%20Developers

Mat

unread,
Sep 13, 2017, 3:43:30 PM9/13/17
to TiddlyWikiDev
If what you want is some action to take place when you click a link, then the easiest is to make a button (see buttonwidget) that you style to look like a link.
tiddlywiki.com has instructions for this.

<:-)

Aigars Rogozovs

unread,
Sep 14, 2017, 2:26:18 AM9/14/17
to TiddlyWikiDev
I want to add feature, when user click on link in tiddler, script take tags from new tiddler and close already opened tags with same tiddler

Maybe this can explain more: http://prntscr.com/gky4y1 :D

A.

BJ

unread,
Sep 14, 2017, 7:19:36 AM9/14/17
to tiddly...@googlegroups.com
create you list like this:
(note replace the filter "[tag[tests]]" with your own filter)

<$list filter="[tag[tests]]">
<$button class="tc-btn-invisible tc-tiddlylink">
<<currentTiddler>>
<$action-navigate/>
<$list filter="[tag<currentTiddler>]">
<$action-sendmessage $message="tm-close-tiddler"/>
</$list>
</$button>
</$list>



all the best

BJ
Reply all
Reply to author
Forward
0 new messages