Eric - I'm really not trying to test your patience... I'm just trying to understand. Before I wade in below, I came up with a simple test to prove your theory - I can confirm that "your place" is fine and works as expected, thus: <script> alert(story.findContainingTiddler(place).id); // always correct ! </script> Note, no function, just pure ILJS ;)
Now... > When the <script>...</script> is processed, InlineJavascriptPlugin > (ILJS) automatically defines a local 'place' variable. This value is > *not* a global variable, and is only valid during the actual > processing of the <script>...</script>. One the script has been > processed, the 'place' variable defined by ILJS goes away. Yep - a good ole local variable - I'm happy with that. > However, > the window.clicker() function you declared in the script is will still > be defined (since it was added to the global 'window' object). It has an execution context "scope" outside of and persists after the relevant ILJS element. I'm happy with that too. > I think your confusion arises because there is 'window.place' variable > that *is* globally-defined, Now THAT I was not aware of. Starting to make some sense now. >and usually refers to the last tiddler > that was rendered it remembers the tiddler that was current at the time it was assigned - which becomes the first tiddler in the story later when more are added beneath. My confusion arises because I expected each successive rerendering of the window.clicker would overwrite the previous along with a reassignment of "place" in the process. All that amounts to - it remembers the FIRST tiddler rendered in the story, not the last tiddler rendered - which is ... well, weird, on the face of it. Understandable now though. > (which is not necessarily the same tiddler at that > which contains your HTML/script content). Note that, in the absence > of a locally-defined 'place' variable (i.e., the one created by ILJS), > any reference to 'place' within your function will implicitly access > 'window.place'. Well it will find the next one "back" in the exec-context/chain - right? Are we shooting for window.place or do you KNOW that is the only other place in the chain? (Again, I just want to understand!) > In conclusion, the correct (and only) way to get the current > containing tiddler from a globally-defined onclick event handler is as > we've already discussed: > > var place=story.findContainingTiddler(resolveTarget(event)); lol - I don't think I should do that exactly... might confuse me even more :))) Ruzz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/TiddlyWiki?hl=en -~----------~----~----~----~------~----~------~--~---

