Module: Core/Controller

The controller manages the loading and unloading of layouts.

Extending controller

Applications may choose to extend the controller to provide a custom implementation. Your custom controller class name should be the capitalized appID for your application followed by the word "Controller".

Example:

SUGAR.App.PortalController = SUGAR.App.controller.extend({
    loadView: function(params) {
       // Custom implementation of loadView
       // Should call super method:
       SUGAR.App.Controller.prototype.loadView.call(this, params);
    }
});

Members


context :Core/Context

The primary context of the app. This context is associated with the root layout.

Type:

Methods


initialize()

Instantiates the application's main context and binds global events.


loadAdditionalComponents(components)

Creates, renders, and registers within the app additional components.

Parameters:
Name Type Description
components Object

The components to load. They will be created using metadata view definitions and rendered on the page. The components objects are cached in the the global SUGAR.App variable under the additionalComponents property.


loadView(params)

Loads a layout.

Sets the context with the given params, creates the layout based on metadata, loads the data and renders it. It also disposes the previous displayed layout. This method is called by the router when the route is changed.

Parameters:
Name Type Description
params Object

Properties to set to the context and used to determine the layout to load.

Properties
Name Type Argument Default Description
layout string

The layout name. It will be used to grab the corresponding metadata.

module string

The module the layout belongs to.

skipFetch boolean <optional>
false

If true, do not fetch the data.