> I am curious though, why did the story.findContainingTiddler(place); > throw an error? Also, I noticed that sometimes, it is used as > story.findContainingTiddler(this);. Can someone explain the reason?
'place' is the current DOM element into which wiki source content is being rendered. 'tiddler' is the current tiddler object in which that wiki source content is stored. These values are passed into each macro.handler() function, so that macros can produce suitable output. In addition, 'place' and 'tiddler' are also defined as global variables (i.e., window.place and window.tiddler) that are automatically set by the TWCore. This allows fields from these objects to be referenced from within *evaluated parameters* in a macro (e.g. <<someMacro {{tiddler.title}}>>). 'place' and 'tiddler' are also automatically defined by InlineJavascriptPlugin, so that these global variables are also available for use within inline scripting. In contrast, 'this' is an automatic 'context variable' defined by the browser's Javascript runtime environment, and is a reference to the current object within the scope of the function being processed. This is particularly important when processing an event handler (such as onclick="..."). In the context of the handler, 'this' refers to the object associated with the handler function (i.e., the link element that was clicked on). Summary: When writing macro code (or inline Javascript code), use 'place' to refer to the element that triggered the event processing. When writing embedded HTML handlers (i.e., onclick="..."), use 'this' for the same purpose. Note: InlineJavascriptPlugin has special handling for 'place'. Normally, 'place' refers to the DOM element in which the script is embedded, so that script output can be inserted in place of the script itself. However, when using the label="..." optional syntax to create an onClick handler, 'place' refers to the clicked link element (i.e., just like the browser-internal 'this') so that you can programmatically adjust the link element (e.g., change it's text when it is clicked on). In this specific use-case, you will need to refer to 'place.parentNode' to generate and render script output (which will follow the clickable link element). enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... http://www.TiddlyTools.com/#Donations Professional TiddlyWiki Consulting Services... Analysis, Design, and Custom Solutions: http://www.TiddlyTools.com/#Contact -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to tiddlywiki@googlegroups.com. To unsubscribe from this group, send email to tiddlywiki+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/tiddlywiki?hl=en.