dijit/_TemplatedMixin (version 1.10)

dijit/_AttachMixin

Summary

Mixin for widgets that are instantiated from a template

Usage

var foo = new _TemplatedMixin(params,srcNodeRef);
dijit/_AttachMixin
Parameter Type Description
params Object | null

Hash of initialization parameters for widget, including scalar values (like title, duration etc.) and functions, typically callbacks like onClick. The hash can contain any of the widget's properties, excluding read-only properties.

srcNodeRef DOMNode | String
Optional

If a srcNodeRef (DOM node) is specified, replace srcNodeRef with my generated DOM tree.

See the dijit/_TemplatedMixin reference documentation for more information.

Property Summary

  • _attachEventsList of connections associated with data-dojo-attach-event=... in the template
  • _attachPointsList of widget attribute names associated with data-dojo-attach-point=... in the template, ex: ["containerNode", "labelNode"]
  • _renderedNot normally use, but this flag can be set by the app if the server has already rendered the template, i.e. already inlining the template for the widget into the main page.
  • _skipNodeCache
  • _templateCache
  • attachScopeObject to which attach points and events will be scoped.
  • searchContainerNode
  • templatePathPath to template (HTML file) for this widget relative to dojo.baseUrl.
  • templateStringA string that represents the widget template.

Method Summary

  • _attach(node,type,func) Roughly corresponding to dojo/on, this is the default function for processing a data-dojo-attach-event.
  • _attachTemplateNodes(rootNode) Iterate through the dom nodes and attach functions and nodes accordingly.
  • _beforeFillContent()
  • _detachTemplateNodes() Detach and clean up the attachments made in _attachtempalteNodes.
  • _escapeValue(val) Escape a value to be inserted into the template, either into an attribute value (ex: foo="${bar}") or as inner text of an element (ex: ${foo})
  • _fillContent(source) Relocate source contents to templated container node. this.containerNode must be able to receive children, or exceptions will be thrown.
  • _processTemplateNode(baseNode,getAttrFunc,attachFunc) Process data-dojo-attach-point and data-dojo-attach-event for given node or widget.
  • _stringRepl(tmpl) Does substitution of ${foo} type properties in template string
  • buildRendering() Construct the UI for this widget from a template, setting this.domNode.
  • destroyRendering()
  • getCachedTemplate(templateString,alwaysUseString,doc) Static method to get a template based on the templatePath or templateString key

Properties

_attachEvents
Defined by: dijit/_AttachMixin

List of connections associated with data-dojo-attach-event=... in the template

_attachPoints
Defined by: dijit/_AttachMixin

List of widget attribute names associated with data-dojo-attach-point=... in the template, ex: ["containerNode", "labelNode"]

_rendered
Defined by: dijit/_TemplatedMixin

Not normally use, but this flag can be set by the app if the server has already rendered the template, i.e. already inlining the template for the widget into the main page. Reduces _TemplatedMixin to just function like _AttachMixin.

_skipNodeCache
Defined by: dijit/_TemplatedMixin
_templateCache
Defined by: dijit/_TemplatedMixin
attachScope
Defined by: dijit/_AttachMixin

Object to which attach points and events will be scoped. Defaults to 'this'.

searchContainerNode
Defined by: dijit/_TemplatedMixin
templatePath
Defined by: dijit/_TemplatedMixin

Path to template (HTML file) for this widget relative to dojo.baseUrl. Deprecated: use templateString with require([... "dojo/text!..."], ...) instead

templateString
Defined by: dijit/_TemplatedMixin

A string that represents the widget template. Use in conjunction with dojo.cache() to load from a file.

Methods

_attach(node,type,func)
Defined by dijit/_AttachMixin

Roughly corresponding to dojo/on, this is the default function for processing a data-dojo-attach-event. Meant to attach to DOMNodes, not to widgets.

Parameter Type Description
node DOMNode

The node to setup a listener on.

type String

Event name like "click".

func undefined
Returns:undefined
_attachTemplateNodes(rootNode)
Defined by dijit/_AttachMixin

Iterate through the dom nodes and attach functions and nodes accordingly.

Map widget properties and functions to the handlers specified in the dom node and it's descendants. This function iterates over all nodes and looks for these properties:

  • dojoAttachPoint/data-dojo-attach-point
  • dojoAttachEvent/data-dojo-attach-event
Parameter Type Description
rootNode DomNode

The node to search for properties. All descendants will be searched.

_beforeFillContent()
Defined by dijit/_AttachMixin
_detachTemplateNodes()
Defined by dijit/_AttachMixin

Detach and clean up the attachments made in _attachtempalteNodes.

_escapeValue(val)

Escape a value to be inserted into the template, either into an attribute value (ex: foo="${bar}") or as inner text of an element (ex: ${foo})

Parameter Type Description
val String
Returns:undefined
_fillContent(source)

Relocate source contents to templated container node. this.containerNode must be able to receive children, or exceptions will be thrown.

Parameter Type Description
source DomNode
_processTemplateNode(baseNode,getAttrFunc,attachFunc)
Defined by dijit/_AttachMixin

Process data-dojo-attach-point and data-dojo-attach-event for given node or widget. Returns true if caller should process baseNode's children too.

Parameter Type Description
baseNode DOMNode | Widget
getAttrFunc Function

Function to get the specified property for a given DomNode/Widget.

attachFunc Function
Optional

Attaches an event handler from the specified node/widget to specified function.

Returns:boolean
_stringRepl(tmpl)

Does substitution of ${foo} type properties in template string

Parameter Type Description
tmpl undefined
Returns:undefined
buildRendering()

Construct the UI for this widget from a template, setting this.domNode.

destroyRendering()
Defined by dijit/_AttachMixin
getCachedTemplate(templateString,alwaysUseString,doc)

Static method to get a template based on the templatePath or templateString key

Parameter Type Description
templateString String

The template

alwaysUseString Boolean

Don't cache the DOM tree for this template, even if it doesn't have any variables

doc Document
Optional

The target document. Defaults to document global if unspecified.

Returns:Mixed

Either string (if there are ${} variables that need to be replaced) or just a DOM tree (if the node can be cloned directly)

Error in the documentation? Can’t find what you are looking for? Let us know!