> The problem is that functions such as story.displayTiddler() cannot be
> directly invoked from a plugin during startup, because plugins are
> loaded *before* the PageTemplate has been rendered and the
> 'displayArea' DOM element has not yet been created. Thus, there isn't
> a valid 'place' in which to render the tiddler, resulting in the error
> message that was reported.
This is the exact sort of thing I expected to hear. Though, despite
the fact they are not the problem here, all the "best practices"
should be learnt.. at appropriate time.
> Have a look at tiddlywiki.org [1] for some basics. Also search for
> "macros", "plugins" "best practices" there, to get some more info.
> I have created some relatively "simple" button plugins, to get started
> with TW macro programming. Have a look at my helloworld space [2].
I definitely will note all the links, thanks.
> You can define a dummy macro that uses the 'init' function to invoke
> code during startup, but *AFTER* the PageTemplate has been processed:
Aha, an important point. Could you please provide more info about
startup actions' sequence? Probably it's an excessively general
question, but I remember that there are 3 stages of generation of
parameters (cookies, plugins and the new shadowed tiddler.. em, I
don't see it at the TiddlyWiki.com somewhy and don't remember it's
name) -- and such things make an impression that the sequence is
boundless.. may be some general stages to understand this and dig the
details later?
> You can define a dummy macro that uses the 'init' function to invoke
> code during startup, but *AFTER* the PageTemplate has been processed:
>
> ----------
> config.macros.setup = {
> init: function() {
> /* your code here, e.g.: */
> story.displayTiddler(null,'SomeTiddler');
> }}
>
> ----------
>
> The macro name, 'setup', is really just a toss-away. Since there is
> no handler() function defined, it won't actually be recognized as a
> macro, but will still invoke it's init() function at the appropriate
> time.
Ouch. I my TW which is called dangerous experiments I created a
tiddler named "Dummy macro" with the code
/*{{{*/
config.macros.setup = {
init: function() {
/* your code here, e.g.: */
story.displayTiddler(null,'Dummy macro');
}
}
/*}}}*/
After restarting TW I've faced the fact that this experiment *is*
dangerous a bit :) I saw just an empty screen. I use Opera (latest
version); I clicked ctrl+u to open and edit the code -- I deleted the
content of the "Dummy macro" and restarted -- TW doesn't look like
anything else got hurted, but such a code make pain :) Suspecting a
loop (not probable, though), I changed the line to
story.displayTiddler(null,'Dummy macro introducer');
but the white screen appeared again. Than I repeated this with
FireFox. The same story.. TW v2.6.0.
> Another way to invoke code during startup, but after PageTemplate has
> loaded is to embed the code into content that is displayed at startup
> (e.g. MainMenu, SideBarOptions, etc.) You can use either
> InlineJavascriptPlugin or a TWCore transclusion with evaluated
> parameters, like this:
>
> http://www.TiddlyTools.com/#InlineJavascriptPlugin
> ----------
> <script>
> story.displayTiddler(null,'SomeTiddler');
> </script>
> ----------
Yes, this works, great, thanks!
> TWCore transclusion with eval params:
> ----------
> <<tiddler {{
> story.displayTiddler(null,'SomeTiddler');
> '';}}>>
> ----------
And this is even better (needs less space). What is the value of the
evaluated parameter? I guess the
> '';
part is the one which "returns" the value and the macro just doesn't
include anything, right? Em.. in this case I don't understand when
InlineJavascriptPlugin is more useful..
PS DefaultTiddlers is not what I need because I want the tiddler to be
opened anyway, even if the permalink was used.
The applied part of question is solved; let me however become more
educated :)
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" 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/tiddlywikidev?hl=en.