Book Image

Node.js By Example

Book Image

Node.js By Example

Overview of this book

Table of Contents (18 chapters)
Node.js By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Registering a new user


To handle the registration of users, we need to update both our frontend and backend code. The client-side part of the application will collect the data and the backend will store it in the database.

Updating the frontend

We updated the navigation and now, if users click on the Register link, the app will forward them to a /register route. We have to tweak our router and register a handler in the following way:

var Register = require('./controllers/Register');
Router
.add('register', function() {
  var p = new Register();
  showPage(p);
})

As with the home page, we will create a new controller located in frontend/js/controllers/Register.js, as follows:

module.exports = Ractive.extend({
  template: require('../../tpl/register'),
  components: {
    navigation: require('../views/Navigation'),
    appfooter: require('../views/Footer')
  },
  onrender: function() {
    var self = this;
    this.observe('firstName',  userModel.setter('value.firstName'));
    this.observe('lastName...