Places API Reference

Contents

UI API

 
nokia

Data API

 
nokia

jsMotif

 
jsMotif

Class jsMotif.Template

Class Summary

jsMotif.Template is a template rendering class. It is extended by nokia.places.ui.Template.

new jsMotif.Template (params)

Method Summary

addEvent (rel, name, handler)
This method adds an event handler to a template element.
addEventMap (events)
This method adds an event map to the template.
fetch (jsonObject)
This method renders the received data using the HTML template and returns the result as an HTML string.
getRelMap (node)
This method obtains a map object relating the rel attributes and the DOM elements to which they apply within the caller-supplied DOM node.
registerAttr (name, handler)
This method registers a handler for an attribute in a template DOM node.
render (jsonObject, targetElem)
This method renders the HTML template, using the data and the target element specified by the caller.

Constructor Detail

jsMotif.Template is a template rendering class. It is extended by nokia.places.ui.Template.

new jsMotif.Template(params)
Parameters:
{Object} params
An initialization object with the following properties
  • template - (mandatory) a value which represents a template it can be:
    • a {String} containing HTML elements, e.g '<div><a></a></div>'
    • a {String} containing an existing DOM element id (the template pattern is extracted from the DOM node
    • a {Object} reference to existing DOM node in javascript
  • targetNode - the element into which the template is to be rendered; its value can be:
    • a {String} which represents an existing element id
    • an {Object} which represents a reference to an existing DOM element in JavaScript
  • functions - an object/hashmap which contains a user-defined function that may be used to render or to affect rendering of the element in template.
  • event - an array of objects which specify the events attached to template nodes and the event handlers; each object in the array has the following attributes:
    • rel - a {String} indicating the template node to which to attach the event
    • name - a {String} providing the name of the attached event; the supported event names are 'keydown', 'keyup', 'keypress', 'click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'mouseenter', 'mouseleave', 'blur', 'change', 'focus', 'reset', 'select', 'submit', 'abort'
    • handler - a caller-defined {Function} to be invoked when the user triggers the attached event; the function receives the data object as an argument and 'this' within the function refers to the element on which the event was triggered

Method Detail

addEvent (rel, name, handler)
This method adds an event handler to a template element.
Parameters:
{Object} rel
The value of the rel attribute in the template node
{Object} name
The name of the event, for example 'click', 'mouseout', etc.
{Object} handler
An event handler function defined by the caller
addEventMap (events)
This method adds an event map to the template.
Parameters:
{Object} events
An array object assigning events and event handlers to a template node (see also the parameter event in the class contructor)
fetch (jsonObject)
This method renders the received data using the HTML template and returns the result as an HTML string. No events are attached.
Parameters:
{Object} jsonObject
An object containing the data to be rendered
getRelMap (node)
This method obtains a map object relating the rel attributes and the DOM elements to which they apply within the caller-supplied DOM node.
Parameters:
{Object} node
The DOM element in the template; all children of this element are checked for the rel attribute
Returns:
An {Object} mapping the rel attributes and DOM elements
registerAttr (name, handler)
This method registers a handler for an attribute in a template DOM node.
Parameters:
{String} name
The name of the attribute as a string
{Function} handler
A caller-defined attribute handler function
render (jsonObject, targetElem)
This method renders the HTML template, using the data and the target element specified by the caller.
Parameters:
{Object} jsonObject
An object containing the data to be rendered
{Object} targetElem
An optional target element in which to render the data; it is specified as {String) containing the DOM id or a node reference

Copyright © 2011 Nokia. All rights reserved. Terms and Conditions