Page Transitions

If an user is on page /a and click on a link for page /b, following callbacks are executed:

  1. out global.
  2. out for page /a.
  3. in global.
  4. in for page /b.
  5. ready global.
  6. ready for page /b.

When a page is loaded directly from the server or when a page is opened through back/forward browser’s buttons, only ready callbacks are executed.

Callbacks

There are two types of callbacks: global and per-page. First ones are always executed independently on the current page. Second ones are executed only on the given page.

You can set your own callback functions, inside your JavaScript code, in this way:


// Global callbacks

Benjamin.on({
  'init': function() {  },
  'ready': function() {  },
  'out': function(next) { return next(); },
  'in': function(next) { return next(); },
});

// Per-page callbacks

Benjamin.on('/', {
  'ready': function() {  },
  'out': function(next) { return next(); },
  'in': function(next) { return next(); },
});

Benjamin.on('/example', {
  'ready': function() {  },
  'out': function(next) { return next(); },
  'in': function(next) { return next(); },
});

// ...

Note: do not put above callbacks definitions inside jQuery’s $(document).ready.

init ( )

Initialize your things.

ready ( )

The page is ready.

out (next)

The page is going to be changed with another page.

in (next)

The page is changed.


Next: Forms