0 votes
by (2.4k points)
Hey there,

So I think what I'm looking for is easy enough, but I couldn't find what I was looking for...
Basically, I want to be able to click on let's say, a link called "Information characters", which would display its content. And when I'd click on that link again, it would hide back within the link ?

Thanks a lot

3 Answers

+1 vote
by (63.1k points)
selected by
Best answer

My <<message>> macro may or may not do what you want. 

by (2.4k points)
This was exactly what I was looking for. Thanks a lot.
0 votes
by (23.6k points)

You could create a widget like this in a properly tagged passage:

<<widget "swaplink">><<nobr>>

<<capture $args[0] , $args[1]>>
<<linkreplace "$args[0]">>
	<<swaplink $args[1] $args[0]>>


Then use it like this to get the result you want:

<<swaplink "name" "content">>


by (2.4k points)
Hey there !
It's almost it, yet I would like the original link to remain visible, and I'd have to click on that original link to hide the text back. (Meaning the text wouldn't be a link)

Any idea how to do that?
Thanks a lot
+2 votes
by (159k points)

The following should do what you want, it uses jQuery's toggle() function to toggle the displaying of an IDed element.

<<link "Toggle display">>

<div id="the-content" style="display: none">\
The hidden content.

a. The above uses an element ID of the-content but you can change this to any value you wish as long as it's unique within the current page, if you do change the ID then remember to change it in both places that ID appears in.
b. If you plan to have multiple of these toggle links within the same passage then make sure you assign a different unique ID to each <<link>> and it's associated div element.

by (2.4k points)
Thanks a lot ! I took Chapel's <<message>> macro for simplicity, but your help is always appreciated !