[TW5] Is there a built-in method for retrieving a macro's calling tiddler element/DOM node?

69 views
Skip to first unread message

Novan Leon

unread,
Nov 5, 2016, 6:06:35 PM11/5/16
to TiddlyWiki
QUESTION: Is there a built-in method for retrieving a macro's or widget's calling tiddler element/DOM node?

For example, in TWC you could use story.findContainingTiddler(popup_element) to find a popup's calling tiddler's DOM node.

Identifying the calling tiddler element provides a way to set the context for traversing the DOM node tree for a specific tiddler (as opposed to say, the entire "document").

Jeremy Ruston

unread,
Nov 6, 2016, 2:47:46 PM11/6/16
to tiddl...@googlegroups.com
Hi Novan

QUESTION: Is there a built-in method for retrieving a macro's or widget's calling tiddler element/DOM node?

Just to clarify the question, JavaScript macros are invoked with “this” pointing to the widget in whose context the macro is to be evaluated, just as a method of the widget object would be.

Anyhow, widgets have a couple of standard properties that connect them to the DOM tree:

* domNodes, an array of references to the DOM nodes created by the widget itself
* parentDomNode, a reference to the immediate parent DOM node of the widget

For example, in TWC you could use story.findContainingTiddler(popup_element) to find a popup's calling tiddler's DOM node.

In TW5, there’s far less direct manipulation of the DOM. Unlike TWC, state is not kept in the DOM; instead the DOM is dynamically recreated as required from the state data stored in tiddlers.

Best wishes

Jeremy.

Identifying the calling tiddler element provides a way to set the context for traversing the DOM node tree for a specific tiddler (as opposed to say, the entire "document”).




--
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/19e56524-68c4-44df-af5d-8ad486580a41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Novan Leon

unread,
Nov 7, 2016, 1:47:13 PM11/7/16
to TiddlyWiki
That helps. Thanks.
Reply all
Reply to author
Forward
0 new messages