diff --git a/docs/client/full-api/api/templates.md b/docs/client/full-api/api/templates.md index ff355e602e..99cdf18dc8 100644 --- a/docs/client/full-api/api/templates.md +++ b/docs/client/full-api/api/templates.md @@ -120,6 +120,16 @@ These callbacks fire once and are the first group of callbacks to fire. Handling the `created` event is a useful way to set up values on template instance that are read from template helpers using `Template.instance()`. +```javascript +Template.myPictures.onCreated(function () { + // set up local reactive variables + this.dataVar = new ReactiveVar("some value"); + + // register this template within some central store + GalleryTemplates.push(this); +}); +``` + {{> autoApiBox "Template#onDestroyed"}} These callbacks are called when an occurrence of a template is taken off @@ -131,6 +141,15 @@ This group of callbacks is most useful for cleaning up or undoing any external effects of `created` or `rendered` groups. This group fires once and is the last callback to fire. +```javascript +Template.myPictures.onDestroyed(function () { + // deregister from some central store + var positionInStore = GalleryTemplates.indexOf(this); + if (positionInStore !== -1) + GalleryTemplates.splice(positionInStore, 1); +}); +``` +

Template instances