jQuery.Controller.prototype.setup  function     

Setup is where most of controller's magic happens. It does the following:

Sets this.element

The first parameter passed to new Controller(el, options) is expected to be an element. This gets converted to a jQuery wrapped element and set as this.element.

Adds the controller's name to the element's className.

Controller adds it's plugin name to the element's className for easier debugging. For example, if your Controller is named "Foo.Bar", it adds "foo_bar" to the className.

Saves the controller in $.data

A reference to the controller instance is saved in $.data. You can find instances of "Foo.Bar" like:

$("#el").data("controllers")['foo_bar'].

Binds event handlers

Setup does the event binding described in Listening To Events.

API

controller.setup(element, options) -> undefined
{HTMLElement}

the element this instance operates on.

{optional:Object}

option values for the controller. These get added to this.options.

{undefined}
© Jupiter IT - JavaScriptMVC Training and Support