-
Notifications
You must be signed in to change notification settings - Fork 3
Controllers
Jesper Lindström edited this page Jun 8, 2014
·
1 revision
Controllers are located in app/controllers/*.js
and are supposed to listen for a specific URL and respond appropriately, with a view or certain action.
app.core.router.get('/page', function() {
// Render the view app/views/page.html and output it at #main
app.core.view.render('page', { name: 'Jesper' }, '#main');
});
The third argument of app.core.view.render()
which is the CSS selector, is optional and defaults to #main
. It also accepts a callback function with one argument, which will contain the rendered HTML. If you want to do something after the view has loaded, you can pass a callback function (without any arguments) as the fourth argument.