1234567

If you want to build your site’s frontend with the single-page application (SPA) model, this hands-on book shows you how to get the job done with Backbone.js. You’ll learn how to create structured JavaScript applications, using Backbone’s own flavor of model-view-controller (MVC) architecture.

Start with the basics of MVC, SPA, and Backbone, then get your hands dirty building sample applications—a simple Todo list app, a RESTful book library app, and a modular app with Backbone and RequireJS. Author Addy Osmani, an engineer for Google’s Chrome team, also demonstrates advanced uses of the framework.

  • Learn how Backbone.js brings MVC benefits to the client-side
  • Write code that can be easily read, structured, and extended
  • Work with the Backbone.Marionette and Thorax extension frameworks
  • Solve common problems you’ll encounter when using Backbone.js
  • Organize your code into modules with AMD and RequireJS
  • Paginate data for your Collections with the Backbone.Paginator plugin
  • Bootstrap a new Backbone.js application with boilerplate code
  • Use Backbone with jQuery Mobile and resolve routing problems between the two
  • Unit-test your Backbone apps with Jasmine, QUnit, and SinonJS

Addy Osmani

Addy Osmani is a writer, speaker, and a JavaScript developer.He is a member of the jQuery core [Bug Triage/Docs/Learning] teams where helps with bugs, documentation, and developer evangelism.

When not working at AOL his personal OS projects include jQuery UI Bootstrap and TodoMVC, which help developers compare JavaScript MVC frameworks. Addy is the author of the popular ebook, Essential JavaScript Design Patterns. His personal blog is http://addyosmani.com/blog/

  • Chapter 1 Introduction

    1. What Is MVC?

    2. What Is Backbone.js?

    3. When Do I Need a JavaScript MVC Framework?

    4. Why Consider Backbone.js?

    5. Setting Expectations

  • Chapter 2 Fundamentals

    1. MVC

    2. What Does MVC Give Us?

    3. Fast Facts

  • Chapter 3 Backbone Basics

    1. Getting Set Up

    2. Models

    3. Views

    4. Collections

    5. RESTful Persistence

    6. Events

    7. Routers

    8. Backbone’s Sync API

    9. Dependencies

    10. Summary

  • Chapter 4 Exercise 1: Todos—Your First Backbone.js App

    1. Static HTML

    2. Todo Model

    3. Todo Collection

    4. Application View

    5. Individual TodoView

    6. Startup

    7. In Action

    8. Completing and Deleting Todos

    9. Todo Routing

    10. Summary

  • Chapter 5 Exercise 2: Book Library—Your First RESTful Backbone.js App

    1. Setting Up

    2. Wiring in the Interface

    3. Creating the Backend

    4. Talking to the Server

    5. Summary

  • Chapter 6 Backbone Extensions

    1. MarionetteJS (Backbone.Marionette)

    2. Thorax

    3. Summary

  • Chapter 7 Common Problems and Solutions

    1. Working with Nested Views

    2. Managing Models in Nested Views

    3. Rendering a Parent View from a Child View

    4. Disposing View Hierarchies

    5. Rendering View Hierarchies

    6. Working with Nested Models or Collections

    7. Better Model Property Validation

    8. Avoiding Conflicts with Multiple Backbone Versions

    9. Building Model and View Hierarchies

    10. Event Aggregators and Mediators

  • Chapter 8 Modular Development

    1. Organizing Modules with RequireJS and AMD

    2. Summary

  • Chapter 9 Exercise 3: Your First Modular Backbone and RequireJS App

    1. Overview

    2. Markup

    3. Configuration Options

    4. Modularizing Our Models, Views, and Collections

    5. Route-Based Module Loading

    6. An Asset Package Alternative for Dependency Management

  • Chapter 10 Paginating Backbone.js Requests and Collections

    1. Backbone.Paginator

    2. Paginator.requestPager

    3. Paginator.clientPager

  • Chapter 11 Backbone Boilerplate and Grunt-BBB

    1. Getting Started

    2. Creating a New Project

    3. Other Useful Tools and Projects

    4. Summary

  • Chapter 12 Backbone and jQuery Mobile

    1. Mobile App Development with jQuery Mobile

    2. Basic Backbone App Setup for jQuery Mobile

    3. Workflow with Backbone and jQueryMobile

    4. Applying Advanced jQM Techniques to Backbone

  • Chapter 13 Jasmine

    1. Behavior-Driven Development

    2. Suites, Specs, and Spies

    3. beforeEach() and afterEach()

    4. Shared Scope

    5. Getting Set Up

    6. TDD with Backbone

    7. Models

    8. Collections

    9. Views

    10. Exercise

    11. Further Reading

    12. Summary

  • Chapter 14 QUnit

    1. Getting Set Up

    2. Assertions

    3. Adding Structure to Assertions

    4. Assertion Examples

    5. Fixtures

    6. Asynchronous Code

  • Chapter 15 SinonJS

    1. What Is SinonJS?

    2. Stubs and Mocks

    3. Exercise

    4. Further Reading and Resources

  • Chapter 16 Conclusions