[tw] Re: Javascript in ViewTemplate (or other ...Template)
Thanks all! @whatever: no, the script is the bit /being/ transcluded. @Eric: cool, very useful functions. @Mario: you're right, making it as a new macro is a lot cleaner. Much better now :) =K= -- 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.
[tw] Re: Javascript in ViewTemplate (or other ...Template)
On Mar 30, 2:36 pm, Kosmaton wrote: > Seems to work well. Maybe there are less macgyvery solutions though? Jup. Since you used the tiddler macro to call a tiddler, that contains a script, You could use a real macro. See how this works at my helloworld space [1]. All macros can be used inside a View/EditTemplate. If done that way, you also can forget about the place.parenNode thing. Which in 99.8% of cases will fail, due to transclusion. The top info table is a little bit overkill. But I think deleting what's not needed is less work, than creating it :) -m http://helloworld.tiddlyspace.com/#HelloWorldNamedParamsPlugin -- 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.
[tw] Re: Javascript in ViewTemplate (or other ...Template)
> in ViewTemplate. The tricky bit is how to refer to the tiddler which so > transcludes the script, within the script (if you need that). Given the use > of InlineJavascriptPlugin it can be done with something like > > var transcludingTiddler = place.parentNode.parentNode; > var transcludingTiddlerTitle = transcludingTiddler.id.slice(7); > var transcludingTiddlerHash = store.getTiddler( > transcludingTiddlerTitle).fields._hash; > > to talk about the transcluding tiddler. Beware: MyScript by itself > (untranscluded!) will output "TypeError: > store.getTiddler(transcludingTiddlerTitle) is null". Not a problem by > itself, but this will appear in e.g. not-yet-existing tiddlers. So you may > want to wrap the MyScript div in a Show/HideWhen macro div. > > Seems to work well. Maybe there are less macgyvery solutions though? Try these TWCore functions: get the rendered DOM element for the current tiddler, regardless of how deeply transcluded: var here=story.findContainingTiddler(place); get the current tiddler's title from the DOM element: var title=here.getAttribute('tiddler'); get a custom field value, given a title and field name: var val=store.getValue(title,'_hash'); enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios -- Was this answer useful? If so, please help support TiddlyTools: TiddlyTools direct contributions: (paypal) http://www.TiddlyTools.com/#Donate UnaMesa tax-deductible contributions: http://about.unamesa.org/Participate (paypal) TiddlyWiki consulting: http://www.TiddlyTools.com/#ELSDesignStudios 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.
[tw] Re: Javascript in ViewTemplate?
You could try the HideWhenPlugin [1] in your Templates to selectively display/hide contents based on various tiddler fields. It *would* be useful to be able to use