
Building Single-page Web Apps with Meteor
By :

In Meteor, this
in template helpers is used differently in template callbacks such as created()
, rendered()
, and destroyed()
.
As already mentioned, templates have three callback functions that are fired in different states of the template:
created
: This fires when the template gets initiated but is not yet in the DOM
rendered
: This fires when the template and all its sub templates are attached to the DOM
destroyed
: This fires when the template is removed from the DOM and before the instance of the template gets destroyed
In these callback functions, this
refers to the current template instance. The instance object can access the templates DOM and comes with the following methods:
this.$(selectorString)
: This method finds all elements that match selectorString
and returns a jQuery object from those elements.
this.findAll(selectorString)
: This method finds all elements that match selectorString
, but returns the plain DOM elements.
this.find(selectorString...
Change the font size
Change margin width
Change background colour