This topic applies to

Applies to

SuiteCommerce Advanced

Within a single-page application, routers direct URLs to client-side methods rather than passing an HTTP request to the server. All routers contain a routes property that maps between a partial URL and a method defined within the router. Methods within the router perform different functions including initializing views, models, and collections.

For example, the Address.Router contains the following routes property:

routes: {
      'addressbook': 'addressBook'
   ,   'addressbook/new': 'newAddress'
   ,   'addressbook/:id': 'addressDetailed'

When a user clicks on the Address Book menu item in the My Account application, the router of the Address module intercepts the partial URL (addressbook) and calls the addressBook method. The addressBook method is responsible for initializing the collection containing the list of addresses and initializing the view that displays them. Depending on the module, routers may initialize properties and variables required by the module. They may also contain methods that define the behavior and logic of the module.