mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Dev docs tweaks
This commit is contained in:
parent
92b957f6f8
commit
c8fa52cce4
@ -23,4 +23,4 @@ Welcome to the developer documentation for TiddlyWiki (http://tiddlywiki.com/).
|
||||
** WidgetModules
|
||||
** WikiRuleModules
|
||||
*Original developer documentation
|
||||
** [[Hook Mechanism]]
|
||||
** HookMechanism
|
||||
|
@ -1,19 +1,19 @@
|
||||
created: 20141122200310516
|
||||
modified: 20141122200310516
|
||||
title: Hook Mechanism
|
||||
title: HookMechanism
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
The Hook Mechanism provides a way for plugins to hook into and modify default functionality. Hooks can be added to the wiki by calling the following from a plugin:
|
||||
The hook mechanism provides a way for plugins to intercept and modify default functionality. Hooks are added as follows:
|
||||
|
||||
``$tw.hooks.addHook(name,function definition);``
|
||||
``$tw.hooks.addHook(name,handler);``
|
||||
|
||||
Multiple hooks can be appended to the same name using repeated calls to the above. When a hook is invoked by name all registered functions will be called seqentially in their order of addition.
|
||||
Multiple handlers can be assigned to the same name using repeated calls. When a hook is invoked by name all registered functions will be called sequentially in their order of addition.
|
||||
|
||||
Though not essential care should be taken to ensure that hooks are added before they are invoked. For example: [[Hook: tc-opening-default-tiddlers-list]] should ideally be added before the story widget is invoked otherwise any hook specified additions to the default tiddlers will not be seen on the initial loading of the page, though will be visible if the user clicks the home button.
|
||||
Though not essential care should be taken to ensure that hooks are added before they are invoked. For example: [[Hook: tc-opening-default-tiddlers-list]] should ideally be added before the story startup module is invoked otherwise any hook specified additions to the default tiddlers will not be seen on the initial loading of the page, though will be visible if the user clicks the home button.
|
||||
|
||||
!!Example
|
||||
!! Example
|
||||
|
||||
A working example of addition to a hook that adds "test" to the default tiddlers.
|
||||
A working example of a hook that adds "test" to the default tiddlers.
|
||||
|
||||
```javascript
|
||||
$tw.hooks.addHook("th-opening-default-tiddlers-list",function(list) {
|
||||
|
@ -3,6 +3,8 @@ modified: 20141122200310516
|
||||
title: Hook: tc-opening-default-tiddlers-list
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
This hook allows plugins to add aditional tiddlers to those specified in [[$:/DefaultTiddlers]].
|
||||
This hook allows plugins to add to or remove from the list of tiddlers that are opened when the wiki is first loaded or the home button is clicked.
|
||||
|
||||
The function definition takes a list of tiddlers as it's argument and should return a modified list of tiddlers to display when the wiki is first loaded or the home button is pressed. This hook is invoked after ``$tw.wiki.filterTiddlers`` is called on the contents of [[$:/DefaultTiddlers]] and it is therfore not correct to append additional filters to the list argument as they will not be subsequently applied.
|
||||
The function takes a list of tiddlers as its only argument and returns a modified list of tiddler titles to display.
|
||||
|
||||
Note that this hook is invoked with the tiddler titles that are generated from the filter in [[$:/DefaultTiddlers]]. Any added entries must be tiddler titles, not filter expressions.
|
||||
|
Loading…
Reference in New Issue
Block a user