Home Manual Reference Source Repository
public class | source

AppRouter

Extends:

EventsRouter → AppRouter

Provides a basic Backbone.Router to route between app states: all, active & completed. When a user navigates between these different filter type states Backbone.history.navigate is invoked in App.js->selectFilter to update the navigation history allowing the user to use the back and forward browser controls to navigate the app. When a filter type is selected it is referenced in the current URL for the web app. If this URL is navigated to and the user is still logged into the app AppRouter will set the AppState accordingly and ManageTodosView will appropriately show the Items for the current user given the filter state set below. If a user is not logged in App.js renders the login view and AppRouter will replace any route matches with no hash tag.

Please note that in App.js->s_INITIALIZE_ROUTES a default catch all no route callback is specified which handles unmatched routes.

Constructor Summary

Public Constructor
public

Creates the routes delegated to the given methods specified.

Method Summary

Public Methods
public

active()

Handles the active route.

public

all()

Handles the all route.

public

Handles the completed route.

Inherited Summary

From class Events
public

bind(): *

Delegates to on.

public

listenTo(obj: object, name: string, callback: function): Events

Tell an object to listen to a particular event on an other object.

public

listenToOnce(obj: object, name: string, callback: function): Events

Just like listenTo, but causes the bound callback to fire only once before being removed.

public

off(name: string, callback: function, context: object): Events

Remove a previously-bound callback function from an object.

public

on(name: string, callback: function, context: object): *

Bind a callback function to an object.

public

once(name: string, callback: function, context: object): *

Just like on, but causes the bound callback to fire only once before being removed.

public

stopListening(obj: object, name: string, callback: function): Events

Tell an object to stop listening to events.

public

Trigger callbacks for the given event, or space-delimited list of events.

public

unbind(): *

Delegates to off.

From class Router
public

Stores the routes hash.

public

execute(callback: function, args: *[], name: string)

Execute a route handler with the provided parameters.

public abstract

Initialize is an empty function by default.

public

navigate(fragment: string, options: object): Router

Simple proxy to Backbone.history to save a fragment into the history.

public

route(route: string | RegExp, name: string, callback: function): Router

Manually bind a single named route to a callback.

Public Constructors

public constructor source

Creates the routes delegated to the given methods specified.

Override:

Router#constructor

Public Methods

public active() source

Handles the active route. If the user is logged in then appState is set to active otherwise the route is replaced in the browser history with no route.

public all() source

Handles the all route. If the user is logged in then appState is set to all otherwise the route is replaced in the browser history with no route.

public completed() source

Handles the completed route. If the user is logged in then appState is set to completed otherwise the route is replaced in the browser history with no route.