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".


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


context :Core/Context

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




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


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

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.


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.

Name Type Description
params Object

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

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>

If true, do not fetch the data.