> not.  If I pick X from a menu while others are displayed, the others
> are closed as advertised.  However, if X is already on screen when
> others are displayed, and I re-pick X from the menu the others are not
> closed.

This is a side-effect of the core's handling for displayTiddler()....

If a tiddler is not already displayed, then clicking a link to it
parses and renders it as usual.  However, if a tiddler is already
displayed, then clicking the link merely scrolls that previously
rendered tiddler into view, *without* re-rendering it's content.

At first glance, it might seem that the fix would be to have the
CloseOtherTiddlers script simply trigger a re-rendering of the tiddler
as well.  Unfortunately, this would be cause an infinite loop, because
every time the tiddler is rendered it triggers the 're-render'
function, which causes it to be rendered again, which triggers the
function... etc.

Another way to implement the 'close others' behavior would be to
create a special *link* for the desired tiddler, so that **clicking
the link** triggers the 'close others' processing, rather than binding
it to the **display** of the tiddler itself.

Using HTML embedded in tiddler content, you can write:

<html><nowiki>
<a href="javascript:;"
   class="TiddlyLinkExisting"
   tid="NameOfTiddler"
   onclick="
      story.closeAllTiddlers(this.tid);
      story.displayTiddler(null,this.tid);
      story.refreshTiddler(this.tid,null,true);
      return false;
">link text goes here</a></html>

The three lines of code in the onclick handler do the following:
1) close tiddlers except the 'target' title
2) display the target tiddler (in case not already shown)
3) force a refresh of the content in the target tiddler (re-renders if
already shown)

This approach doesn't cause an infinite loop because the call to
story.refreshTiddler() is not being triggered by the refresh itself,
but rather by the click on the link that occurs just once.

Of course, this doesn't help when a link to the target title simply
occurs in context within your tiddler content.  Such a link would
simply open the tiddler as usual, without the added closeOtherTiddlers
() functionality.

In order to get the link behavior you want, you would have to embed
the same HTML syntax for each link, which would be a real nuisance.
To make it much easier to embed the above HTML link into several
places without repeating the HTML code in each instance, you can put
the <html>...</html> block into a 'hidden section' at the end of the
target tiddler, like this:
   /%
   !closeOthers
   <html>...</html>
   !end
   %/

Then, you can embed the section content (i.e., the HTML link syntax)
into any other tiddler like this:
   <<tiddler NameOfTiddler##closeOthers>>

Although not a succinct as simply writing "NameOfTiddler", if there
are only a few of these special target tiddlers, this might be
sufficient for your purposes and not too much of a hassle.

enjoy,
-e





--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to