Note: An alternative skin, TW4MW (work in progress), is available from the user preferences.

Dev:DisplayTiddler

TiddlyWiki Community Wiki

Jump to: navigation, search

The displayTiddler method of the Story class works the same way that the createTiddler method does, except that the newly-displayed tiddler is animated opening, and the browser window scrolls to display it. This method takes five parameters:

  • the parent DOM element to display the tiddler inside (required but may be null if the tiddler already exists, or the special strings "bottom" and "top" to place the newly created tiddler at the bottom or top of the story)
  • the title of the tiddler or a tiddler itself
  • optionally the template to view the tiddler as. This should be either the constant DEFAULT_VIEW_TEMPLATE or DEFAULT_EDIT_TEMPLATE.
  • optionally a boolean value indicating whether to animate opening the tiddler
  • optionally a boolean value indicating whether to animate slowly. To see this in action, hold down the Shift, Option, or Alt key when clicking a tiddler link.

This method does not return any values.

//# Display a given tiddler with a given template. If the tiddler is already displayed but with a different
//# template, it is switched to the specified template. If the tiddler does not exist, and if server hosting
//# custom fields were provided, then an attempt is made to retrieve the tiddler from the server
//# srcElement - reference to element from which this one is being opened -or-
//#              special positions "top", "bottom"
//# tiddler - tiddler or title of tiddler to display
//# template - the name of the tiddler containing the template -or-
//#            one of the constants DEFAULT_VIEW_TEMPLATE and DEFAULT_EDIT_TEMPLATE -or-
//#            null or undefined to indicate the current template if there is one, DEFAULT_VIEW_TEMPLATE if not
//# animate - whether to perform animations
//# customFields - an optional list of name:"value" pairs to be assigned as tiddler fields (for edit templates)
//# toggle - if true, causes the tiddler to be closed if it is already opened
//# animationSrc - optional. If provided, this will specify the element which is to act as the start of the animation -or-
//#                the source of the animation will be the srcElement.

[edit] Examples

story.displayTiddler(null, "Title of an Existing Tiddler");
story.displayTiddler("bottom", "Title of Tiddler To Create", DEFAULT_EDIT_TEMPLATE);
Personal tools