You are previewing Building Node Applications with MongoDB and Backbone.

Building Node Applications with MongoDB and Backbone

Cover of Building Node Applications with MongoDB and Backbone by Mike Wilson Published by O'Reilly Media, Inc.

Chapter 8. Making Friends

Now that users are able to log into the application, retrieve their lost passwords, and create new accounts, they need a way to connect to one another; in other words, it’s time to put the social aspect into this social network.

In Chapter 7 the contact list was described and scaffolded into the user interface; in this chapter you will add functionality to allow accounts to link to each other, publicize those relationships, and track each other’s progress.

Contact List

The contact list’s purpose is to aggregate all of an account’s contacts into a single view, displaying only the most recent and top-level information about each relationship. The list will also expose a means to search for new contacts.

Contact List Template

The template controlling the contacts view is not very different from the templates you created for status and activity updates. Like the status update controller, the contact list is responsible for generating an overall “container” page as well as each of the “child” elements containing contacts belonging to the account. Unlike the status page in Chapter 7, the contact page will not need to load and display a model class; this makes a collection object a perfect choice to store the models.

Unlike the status views, when the contact list is found or updated, the new entry will not be animated to the screen. Instead, the entire contact list will refresh. To accomplish this, bind the render function on the collection’s reset event during the ...

The best content for your career. Discover unlimited learning on demand for around $1/day.