Book description
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
Publisher resources
Table of contents
- Developing Backbone.js Applications
- Preface
- 1. Introduction
- 2. Fundamentals
-
3. Backbone Basics
- Getting Set Up
- Models
- Views
-
Collections
- Adding and Removing Models
- Retrieving Models
- Listening for Events
- Resetting/Refreshing Collections
-
Underscore Utility Functions
- forEach: Iterate over collections
- sortBy(): Sort a collection on a specific attribute
- map(): Create a new collection by mapping each value in a list through a transformation function
- min()/max(): Retrieve item with the min or max value of an attribute
- pluck(): Extract a specific attribute
- filter(): Filter a collection
- indexOf(): Return the item at a particular index within a collection
- any() : Confirm if any of the values in a collection pass an iterator truth test
- size(): Return the size of a collection
- isEmpty(): Determine whether a collection is empty
- groupBy(): Group a collection into groups like items
- pick(): Extract a set of attributes from a model
- omit(): Extract all attributes from a model except those listed
- keys() and values(): Get lists of attribute names and values
- pairs(): Get list of attributes as [key, value] pairs
- invert(): Create object in which the values are keys and the attributes are values
- Chainable API
- RESTful Persistence
- Events
- Routers
- Backbone’s Sync API
- Dependencies
- Summary
- 4. Exercise 1: Todos—Your First Backbone.js App
- 5. Exercise 2: Book Library—Your First RESTful Backbone.js App
- 6. Backbone Extensions
-
7. Common Problems and Solutions
- Working with Nested Views
- Managing Models in Nested Views
- Rendering a Parent View from a Child View
- Disposing View Hierarchies
- Rendering View Hierarchies
- Working with Nested Models or Collections
- Better Model Property Validation
- Avoiding Conflicts with Multiple Backbone Versions
- Building Model and View Hierarchies
- Event Aggregators and Mediators
-
8. Modular Development
-
Organizing Modules with RequireJS and AMD
- Maintainability Problems with Multiple Script Files
- Need for Better Dependency Management
- Asynchronous Module Definition (AMD)
- Writing AMD Modules with RequireJS
- Getting Started with RequireJS
- Require.js and Backbone Examples
- Keeping Your Templates External Using RequireJS and the Text Plug-in
- Optimizing Backbone Apps for Production with the RequireJS Optimizer
- Summary
-
Organizing Modules with RequireJS and AMD
- 9. Exercise 3: Your First Modular Backbone and RequireJS App
- 10. Paginating Backbone.js Requests and Collections
- 11. Backbone Boilerplate and Grunt-BBB
- 12. Backbone and jQuery Mobile
- 13. Jasmine
- 14. QUnit
-
15. SinonJS
-
What Is SinonJS?
- Basic Spies
- Spying on Existing Functions
-
Inspection Interface
- Matching arguments: Test that a spy was called with a specific set of arguments
- Stricter argument matching: Test that a spy was called at least once with specific arguments and no others
- Testing call order: Test that a spy was called before or after another spy
- Match execution counts: Test that a spy was called a specific number of times
- Stubs and Mocks
- Exercise
- Further Reading and Resources
-
What Is SinonJS?
- 16. Conclusions
- A. Further Learning
- B. Resources
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: Developing Backbone.js Applications
- Author(s):
- Release date: May 2013
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449328559
You might also like
book
Beginning Backbone.js
Beginning Backbone.js is your step-by-step guide to learning and using the Backbone.js library in your web …
book
Full Stack Web Development with Backbone.js
Learn how to build a full-stack application with Backbone.js by taking advantage of JavaScript modules, workflow …
book
Backbone.js Testing
If you dread the business of testing JavaScript and Backbone.js web applications, this book is your …
book
Mastering Backbone.js
Design and build scalable web applications using Backbone.js About This Book Level up your Backbone.js skills …