Nokia Maps API Reference

Contents

Class nokia.places.widgets.Widget

Class Summary

The Widget class defines a UI component that renders place data, using a template and a JSON data object. It is the base class extended by the classes nokia.places.widgets.Place, nokia.places.widgets.ResultList and nokia.places.widgets.SearchBox.

Method Summary
getData (selector, defaultValue) This method retrieves the rendered data object.
hide () This method hides the rendered widget.
setData (data, (optional)) This method associates data with the given widget and renders the data using a template.
setTemplate (template, [locale, [onTemplate, reRender]]) This method changes the template for the given widget.
show () This method shows the rendered widget.
Constructor Detail

The Widget class defines a UI component that renders place data, using a template and a JSON data object. It is the base class extended by the classes nokia.places.widgets.Place, nokia.places.widgets.ResultList and nokia.places.widgets.SearchBox.

new nokia.places.widgets.Widget(params)
Parameters:
{Object} params An initialization object with the following properties:
  • template - a (mandatory) parameter that represents a template to be used to render place data for display; its value may take one of the following forms:
    • a {String} containing HTML elements that define the template pattern, for example '<div><a></a></div>'
    • a {String} containing the id of an existing DOM element - the template pattern is extracted from the DOM node
    • an {Object} reference to an existing DOM node in JavaScript
  • targetNode - the element in which the template is to be rendered; its value may be one of:
    • a {String} containing the id of an existing element
    • an {Object} reference to an existing DOM element in JavaScript
  • locale - optional; a language designation composed of An ISO 369 lanuage code and an ISO 36166-1 Alpha-2 country code (for example 'cs-cz' stands for Czech as spoken in the Czech Republic; if not specified, the browser language is used
  • moduleParams {Object} - a hash map which specifies the parameters for the modules that render template DOM nodes; for example, this is how you can enable all rating modules specified within the template and set the perPage parameter for every List object used within the template to 5:
             
             moduleParams: {
                 'Rating': {
                     enabled: true
                 },
                 'List': {
                     perPage: 5
                 }
             }
             
             
  • predefined - an object/hashmap containing a user-defined function that may be used to render an element in a template
  • events - an array of objects which specify the events attached to template nodes; each object in the array corresponds to one event and evnet handler and has the following parameters:
    • rel - a {String} that specifies the template node to which to attach the event
    • name - a {String} containing the event name; 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 - {Function}, a user-defined function to be called when the named event has been triggered; the function receives a data object as an argument (a place response object); within the body of the function, this refers to the template node on which the event was triggered
  • onReady - a caller-defined function invoked when the widget is fully initialized and has finished loading templates (from the back-end server or a custom location) and translations (from the back-end); when the function is called, you can invoke widget methods, for example to set data, as follows: this.setData() (this within the scope of the function refers to the widget itself)
  • onRender - a caller-defined function invoked when the widget is fully rendered
Method Detail
getData (selector, defaultValue)
This method retrieves the rendered data object.
Parameters:
selector
defaultValue
Returns:
A JSON object containing the rendered data.
hide ()
This method hides the rendered widget.
setData (data, (optional))
This method associates data with the given widget and renders the data using a template.
Parameters:
{Object} data The data to associate with the widget and to render
{Object} (optional) the target element in which to render the data
setTemplate (template, [locale, [onTemplate, reRender]])
This method changes the template for the given widget.
Parameters:
{Object} template A template object, which may be an HTML string, an existing DOM element id, or a reference to a DOM node (see also class initialization parameters)
{String} [locale]: A language designation composed of An ISO 369 lanuage code and an ISO 36166-1 Alpha-2 country code (for example 'cs-cz' stands for Czech as spoken in the Czech Republic; if not specified the browser language is used
{function} [onTemplate]: A caller-defined function to be executed when a template is applied
{Boolean} reRender A Boolean, if true, the widget is re-rendered with the last used (existing) JSON data object
show ()
This method shows the rendered widget.
Documentation generated on Wed Jun 27 2012 16:54:00 GMT+0200 (CEST).