I'm an undergraduate senior studying interactive text design, and my professor asked me to forward this note that I posted to the class group here.
I feel sure that there must be a known way to change the text of a link passed to the ToggleText tiddler when it is clicked and the hidden text is revealed. I don't claim to know JavaScript to any significant degree, and I'm not familiar enough with the TiddlyWiki community to locate any relevant discussions. So, I apologize if this post is redundant. Thanks! On Friday, February 6, 2015 at 4:38:36 AM UTC-5, leep1 wrote: > > I've just used the ToggleText macro (actually a tiddler transclusion) for > a more seamless text expansion technique. > > ToggleText is a macro with JavaScript code in it. To use it, you use the > *<<tiddler>>* macro and then a keyword "with" to specify the the contents > of the two variables -- the text to be clicked on and the text to be > displayed. > > <<tiddler ToggleText with: "(Text to be clicked)" "Text to be displayed">> > > Don't put a comma or anything but the option space between the two quoted > strings. Inside the strings, you can't use tiddler references, but you can > use standard HTML for links and line breaks (*<br>*) and the like. If you > use *<a>* tags to add links you have to put single quotes instead of > double quotes around the *href* attributes, for clarification. > > Now, I wish I could have the clicked text change after the reader has > clicked it and the hidden text has been revealed. I think this would be > very easy to do with a line of JavaScript. > > Looking at the code in the ToggleText tiddler, the standard variable > *this* references the clicked text: > > <html> > <a href="javascript:;" onclick= > " var s=this.nextSibling.style; > s.display=s.display=='none'?'inline':'none';"> > $1 > </a> > <span style="display:none"> > $2 > </span> > </html> > > I think this addition would theoretically change the clicked text to > something new: > > this.innerHTML="$3"; > > The problem is, the hypothetical variable $3 is not a JavaScript variable. > You could declare a JavaScript variable, but then the contents of the *with: > *attribute of the *<<tiddler>> *macro would not get mapped to the > JavaScript variable. I don't know how to reference this dollar sign > variable notation in JavaScript. > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/d/optout.