How to properly dispatch a tm-navigate event outside of the widget tree?

114 views
Skip to first unread message

Danielo Rodríguez

unread,
Jan 22, 2017, 4:39:54 PM1/22/17
to TiddlyWiki
Hello,

Le'ts say I want to use the console to dispatch a tm-navigate event or a tm-edit-tiddler event. How can I do it ? I'm saying the console because I want to trigger it from outside of the widget tree. I only have access to the $tw object.

Regards

Jeremy Ruston

unread,
Jan 22, 2017, 5:08:35 PM1/22/17
to tiddl...@googlegroups.com
Hi Danielo

Just dispatch the event to $tw.rootWidget

Best wishes

Jeremy

--
Jeremy Ruston

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/7a5d4be2-6ee8-437d-ab06-7cb33dc424b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Danielo Rodríguez

unread,
Jan 22, 2017, 5:49:56 PM1/22/17
to TiddlyWiki
Hello Jeremy,

I tried that too, and it didn't worked

$tw.rootWidget.dispatchEvent({type:"tm-navigate", navigateTo:"Dashboard"})

What's wrong with that dispatch event?

Jeremy Ruston

unread,
Jan 22, 2017, 6:06:18 PM1/22/17
to tiddl...@googlegroups.com
Ah ok, the navigator widget that listens for tm-navigate is a descendent of the root widget, and so won't see messages directed to the root widget.

In the case of navigation you can instead use methods on $tw.story (I think) -- I'm on my phone and so can't consult the docs but you should be able to find it and figure it out

Best wishes

Jeremy

--
Jeremy Ruston

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Danielo Rodríguez

unread,
Jan 22, 2017, 7:00:42 PM1/22/17
to TiddlyWiki

In the case of navigation you can instead use methods on $tw.story (I think) -- I'm on my phone and so can't consult the docs but you should be able to find it and figure it out

I also came to the conclusion of using the story thing, but it is not available on the $tw object. If you don't mind, I will wait until you get a proper computer :-) 

Jeremy Ruston

unread,
Jan 23, 2017, 6:39:21 PM1/23/17
to tiddl...@googlegroups.com
Hi Danielo

I also came to the conclusion of using the story thing, but it is not available on the $tw object. If you don't mind, I will wait until you get a proper computer :-) 

Try this:

var story = new $tw.Story();
story.navigateTiddler(titleOfTiddlerToNavigateTo);

There are more options; consult $:/core/modules/story.js for the details.

Best wishes

Jeremy


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
Reply all
Reply to author
Forward
0 new messages