0%

Book Description

Build amazing high-performance web applications using Backbone.js

In Detail

This book offers insight into creating and maintaining dynamic Backbone.js web applications. It delves into the the fundamentals of Backbone.js and helps you achieve mastery of the Backbone library.

Starting with Models and Collections, you'll learn how to simplify client-side data management and easily transmit data to and from your server. Next, you'll learn to use Views and Routers to facilitate DOM manipulation and URL control so that your visitors can navigate your entire site without ever leaving the first HTML page. Finally, you'll learn how to combine those building blocks with other tools to achieve high-performance, testable, and maintainable web applications.

What You Will Learn

  • Architect a single-page web application using Backbone.js
  • Easily transmit data to and from a server-side API (RESTful or not) using Backbone's Models and Classes
  • Add and modify DOM elements with Backbone Views, and create browsable client-side pages with Routers
  • Document your Backbone.js logic, with or without popular tools such as JSDoc or Docco, to ensure long-term maintainability
  • Prevent bugs and ease refactoring by testing your code with frameworks such as QUnit, Mocha, or Buster and auxiliary tools such as Sinon
  • Use Backbone.js's sister library, Underscore, to realize the full power of a Backbone application
  • Explore advanced Backbone techniques and save time and effort by using the most powerful third-party tools available

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Backbone.js Essentials
    1. Table of Contents
    2. Backbone.js Essentials
    3. Credits
    4. About the Author
    5. Acknowledgments
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Building a Single-Page Site Using Backbone
      1. What is Backbone?
      2. Why choose Backbone?
      3. A Brief History of Web Development
      4. Benefits of Backbone and single-page applications
        1. Full User Interface Asset Control
        2. Simpler Data Management and Event Triggers
        3. Enhanced performance
      5. Backbone and Its Competitors
      6. Summary
    10. 2. Object-Oriented JavaScript with Backbone Classes
      1. JavaScript's class system
      2. The new keyword
      3. Prototypal inheritance
      4. Extending Backbone classes
      5. Applying parent methods
      6. Introducing Underscore
      7. More Underscore
        1. Each, Map, and Reduce
        2. Extend and defaults
        3. Pluck and invoke
        4. Further reading
      8. Summary
    11. 3. Accessing Server Data with Models
      1. The purpose of Models
      2. Attributes, options, and properties
      3. Getters and setters
      4. Listening for events
      5. Available events
        1. Custom events
      6. Server-side actions
        1. Storing URLs on the client
        2. Identification
        3. Fetching data from the server
        4. Saving data to the server
        5. Validation
      7. Return of Underscore
      8. Summary
    12. 4. Organizing Models with Collections
      1. Working with Collections
      2. Collections and Models
      3. Adding to and resetting Collections
      4. Indexing
      5. Sorting
      6. Events
      7. Server-side actions
      8. Underscore methods
      9. Previously mentioned methods
      10. Testing methods
      11. Extraction methods
      12. Ordering methods
      13. Summary
    13. 5. Adding and Modifying Elements with Views
      1. Views are the core of Backbone-powered sites
        1. Instantiating Views
        2. Rendering view content
        3. Connecting Views to Models and Collections
        4. Accessing a View's el element
        5. A brief aside on $Variable names
      2. Handling events
      3. Rendering strategies
        1. Simple templating
        2. Advanced templating
        3. Logic-based
        4. The combined approach
        5. Other render considerations
          1. Child views
          2. Repeatable versus one-time renders
          3. Return value – this or this.$el
      4. Summary
    14. 6. Creating Client-side Pages with Routers
      1. Backbone routers enable single-page applications
      2. How Routers work
      3. Backbone.history
      4. Differences between routes and pages
      5. Creating a new Router
      6. Creating routes
      7. Route styles
      8. A note about routing conflicts
      9. Trailing slashes
      10. Redirects
      11. 404s and other errors
      12. Routing events
      13. Multiple routers
      14. Page views
      15. Summary
    15. 7. Fitting Square Pegs in Round Holes – Advanced Backbone Techniques
      1. Taking it up a notch
      2. Methods in place of properties
        1. Collection.model as a factory method
      3. Overriding a class constructor
      4. Class mixins
      5. Publish/subscribe
      6. Wrapping widgets of other libraries
      7. Summary
    16. 8. Scaling Up – Ensuring Performance in Complex Applications
      1. Backbone and performance
      2. Causes of performance issues
      3. CPU-related performance issues
      4. Event delegation
      5. Bandwidth-related performance issues
        1. Downloading excessively large files
        2. Downloading excessive number of files
      6. Memory-related performance issues
      7. Summary
    17. 9. What Was I Thinking? Documenting Backbone Code
      1. Backbone and documentation
      2. Documentation approaches
      3. The non-documentation approach
        1. Benefits of non-documentation for other approaches
      4. The simple documentation approach
      5. The robust documentation approach
        1. JSDoc
        2. Docco
      6. Summary
    18. 10. Keeping the Bugs Out – How to Test a Backbone Application
      1. Testing in JavaScript?
      2. Which library to use
      3. Getting started with Mocha
        1. TDD versus BDD: What's the difference?
        2. Describe, beforeEach, and it
        3. Running our test
      4. Introducing mocks
      5. Selenium
      6. Summary
    19. 11. (Not) Re-Inventing the Wheel – Utilizing Third-Party Libraries
      1. The Backbone ecosystem
      2. Dependency management with RequireJS
      3. External dependency management with Bower
      4. Paginating with Backbone Paginator
      5. Rendering tables with Backgrid.js
      6. Templating with Handlebars
      7. Automating tasks with Grunt
      8. New syntax with CoffeeScript
      9. Making life easier with BackSupport
      10. Summary
    20. 12. Summary and Further Reading
      1. Putting it all together
      2. What's Syapse?
        1. The 10,000-foot view
        2. The View layer
        3. The Data layer
        4. The Support layer
      3. Building your own Syapse
      4. Further reading
      5. Summary
    21. Index
3.140.185.147