Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Backbone.js Patterns and Best Practices

You're reading from   Backbone.js Patterns and Best Practices Improve your Backbone.js skills with this step-by-step guide to patterns and best practice. It will help you reduce boilerplate in your code and provide plenty of open source plugin solutions to common problems along the way.

Arrow left icon
Product type Paperback
Published in Jan 2014
Publisher Packt
ISBN-13 9781783283576
Length 174 pages
Edition Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Swarnendu De Swarnendu De
Author Profile Icon Swarnendu De
Swarnendu De
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Backbone.js Patterns and Best Practices
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
1. Reducing Boilerplate with Plugin Development 2. Working with Views FREE CHAPTER 3. Working with Models 4. Working with Collections 5. Routing Best Practices and Subrouting 6. Working with Events, Sync, and Storage 7. Organizing Backbone Applications – Structure, Optimize, and Deploy 8. Unit Test, Stub, Spy, and Mock Your App Books, Tutorials, and References Precompiling Templates on the Server Side
Organizing Templates with AMD and Require.js Index

Index

A

  • $.append() method, jQuery
    • using / Avoiding multiple DOM reflow
  • all-in-one router
    • about / The all-in-one router
  • AMD
    • working with / Working with Asynchronous Module Definition
    • about / Working with Asynchronous Module Definition
    • Require.js, adding to application / Adding Require.js to your project
    • dependencies, configuring / Configuring dependencies
    • module, defining / Defining a module
  • appendHtml() method / Working with CompositeView
  • application architecture
    • creating / Creating application architecture
    • project directory, managing / Managing a project directory
    • code organization, AMD used / Organizing code with AMD
    • application, setting up / Setting up an application
    • application, setting up using module pattern / Using the module pattern
    • view management / Understanding view management
    • features / Understanding other important features
  • application directory structure
    • about / Understanding the application directory structure
  • AuraJS
    • benefits / Using the module pattern
  • automatic model-view data binding
    • about / Understanding automatic model-view data binding

B

  • Backbone
    • data validation / Validating the data
    • custom events / Understanding custom events
    • event dispatcher / Using an event dispatcher
    • reference books / Books for reference
    • online tutorials / Tutorials
    • plugins / Other plugins and tutorials
    • tutorials / Other plugins and tutorials
  • Backbone-Debugger
    • about / Other plugins and tutorials
  • Backbone-relational plugin
    • URL / Understanding the relational data model
    • about / Understanding the relational data model
    • features / Understanding the relational data model
    • example / Understanding the relational data model
  • Backbone.Collection
    • about / Basic components of Backbone.js
  • Backbone.Events
    • about / Basic components of Backbone.js
  • Backbone.Events class / Understanding custom events
  • Backbone.js
    • basic components / Basic components of Backbone.js
  • Backbone.js API
    • URL / Working with routers
  • Backbone.LocalStorage adapter
    • used, for offline storage / Offline storage using the Backbone.LocalStorage adapter
  • Backbone.Model
    • about / Basic components of Backbone.js
  • Backbone.Router
    • about / Basic components of Backbone.js
  • Backbone.sync() method
    • overriding / Overriding the Backbone.sync() method
    • overirdding / Overriding the Backbone.sync() method
  • Backbone.Validation plugin
    • using / Using the Backbone.Validation plugin
  • Backbone.View
    • about / Basic components of Backbone.js
  • Backbone app
    • setting up / Setting up an application
    • setting up, module pattern used / Using the module pattern
    • objects and module communication, managing / Managing objects and module communication
    • objects and module communication, managing using observer/PubSub pattern / Using the observer/PubSub pattern
    • objects and module communication, managing using mediator pattern / Using the mediator pattern
  • Backbone components
    • testing, QUnit used / Testing Backbone.js components with QUnit
  • Backbone models
    • usage / Basic usage of models
    • defaults property, using / Using the defaults property
    • object references, avoiding in defaults property / Avoiding object references in the defaults property
    • data operations, with server / Data interaction with the server
    • serializing / Serializing models
  • Backbone views
    • usage / Basic usage of views
    • el property / Understanding the el property
    • view events, listening to / Listening to view events
    • model data, displaying with templates / Displaying model data with templates
    • updating partially / Partially updating a view
    • nested views / Understanding nested views
    • templates, working with / Working with templates
    • automatic model-view data binding / Understanding automatic model-view data binding
  • base router
    • about / The base router
  • baseUrl config
    • about / Configuring dependencies
  • basic test case, QUnit
    • performing / Performing a basic test case
  • beforeRender() method / Using Layout Manager
  • best practices, routers
    • large functional code, avoiding in route methods / Avoiding large functional code in route methods
    • views, instantiating in router methods / Instantiating views in router methods
    • regular expressions, using, for selective routing / Using regular expressions for selective routing

C

  • classic mixins
    • creating / Creating classic mixins
  • close() method / Avoiding memory leaks with the listenTo() method
  • code
    • reusing, with extensions / Re-using code with extensions
    • base class, creating / Creating a base class
  • code organization
    • about / Understanding the application directory structure
  • collection
    • features / Basic usage of collections
    • usage / Basic usage of collections
    • used, for performing data operations / Performing data operations with collections
    • sorting / Sorting a collection
    • sorting, with multiple attributes / Sorting a collection with multiple attributes
    • filtering / Filtering a collection
    • basic filtering, performing / Performing basic filtering
    • filtering, with duplicate collection / Filtering a collection with a duplicate collection
    • self-filtering, with full data pointer / Self-filtering with full data pointers
  • CollectionView class
    • about / CollectionView
    • features / CollectionView
    • close() method / CollectionView
  • CompositeView
    • about / Working with CompositeView
    • functions / Working with CompositeView
    • working with / Working with CompositeView
  • curry() pattern
    • used, for combining function and arguments / Using curry to combine a function and arguments
    • defining / Using curry to combine a function and arguments
  • custom events
    • about / Understanding custom events
    • creating / Understanding custom events
    • case study / A simple case study on custom events

D

  • data-main attribute / Adding Require.js to your project
  • data operations, with collection
    • performing / Performing data operations with collections
    • data, fetching from server / Fetching data from the server
    • data, saving to server / Saving data to the server
  • data operations, with server
    • model, creating / Creating a model
    • model, updating / Updating a model
    • model, fetching / Fetching a model
    • model, deleting / Deleting a model, Validating the data
  • data validation, model
    • about / Validating the data
    • Backbone.Validation plugin, used / Using the Backbone.Validation plugin
    • validation rules, configuring / Configuring validation rules
    • model, prevalidating with preValidate() method / Prevalidating a model with the preValidate() method
  • define() method / Defining a module
  • deps config
    • about / Configuring dependencies
  • destroy() method
    • about / Deleting a model
  • DOM handling
    • about / Understanding other important features

E

  • el property
    • about / Understanding the el property
  • error handler
    • about / Understanding other important features
  • event dispatcher
    • about / Using an event dispatcher
    • issues / Using an event dispatcher
    • multiple event dispatchers, creating / Creating multiple event dispatchers
    • naming convention / Using different event namespaces
  • expect() method / Performing a basic test case
  • exports config
    • about / Configuring dependencies

F

  • fetch() method
    • about / Fetching a model
    / Fetching data from the server
  • findWhere() method / Filtering a collection
  • functional mixins
    • creating / Creating functional mixins
    • mixin functions, caching / Caching mixin functions

G

  • getNameAsArray() method / Testing with spies
  • getUserDetails() method / Using the mediator pattern
  • getView method / Using Layout Manager

I

  • initialize() method / Displaying model data with templates, Re-rendering parent views
  • isPrime() method / Performing a basic test case
  • ItemView
    • about / ItemView
    • functionalities / ItemView
    • serializeData() method / ItemView
    • close() method / ItemView

J

  • JavaScript mixins
    • about / Understanding JavaScript mixins
    • classic mixins, creating / Creating classic mixins
    • functional mixins, creating / Creating functional mixins
  • join() method / Storing templates in a JavaScript file

L

  • Layout Manager
    • about / Using Layout Manager
    • using / Using Layout Manager
    • UserDetails view / Using Layout Manager
    • UserItem view / Using Layout Manager
    • UserList view / Using Layout Manager
    • serialize() method, using / Using Layout Manager
  • listenTo() method / Displaying model data with templates
    • used, for memory management / Avoiding memory leaks with the listenTo() method
  • ListItemView class / What is a mixin?
  • Lo-dash library
    • URL / Using Underscore.js
    • about / Using Underscore.js
  • loadEvents() method / Using the mediator pattern
  • loggedin event / Using an event dispatcher

M

  • Marionette
    • URL / Using Marionette's ItemView, CollectionView, and CompositeView
    • about / Using Marionette's ItemView, CollectionView, and CompositeView
    • ItemView / ItemView
    • CollectionView / CollectionView
    • CompositeView / Working with CompositeView
  • memory management
    • about / Avoiding memory leaks with the listenTo() method, Understanding other important features
    • listenTo() method, using / Avoiding memory leaks with the listenTo() method
    • memory leaks, avoiding with listenTo() method / Avoiding memory leaks with the listenTo() method
  • mixin
    • about / What is a mixin?
  • mMocks
    • testing with / Testing with mocks
    • differenciating, with sStubs / Difference between mocks and stubs
  • model data, views
    • displaying, with templates / Displaying model data with templates
  • module() method, QUnit
    • about / Understanding the QUnit module (), setup (), and teardown () methods
  • multiple event dispatchers
    • creating / Creating multiple event dispatchers
  • multiple filtering
    • disadvantage / Self-filtering with full data pointers
  • multiple model types
    • filtering / Understanding the collection of multiple model types
  • multiple routers
    • about / Understanding other important features

N

  • nested views
    • about / Understanding nested views
    • subviews, using / Knowing when to use subviews

O

  • offline storage
    • Backbone.LocalStorage adapter, used / Offline storage using the Backbone.LocalStorage adapter
  • on() method / Displaying model data with templates
  • online tutorials
    • unit testing / Unit testing

P

  • paths config
    • about / Configuring dependencies
  • plugins
    • developing, without extending base classes / Developing plugins without extending base classes
    • about / Other plugins and tutorials
  • preValidate() method
    • used, for prevalidating model / Prevalidating a model with the preValidate() method

Q

  • QUnit
    • URL / Testing with QUnit
    • about / Testing with QUnit
    • basic test case, performing / Performing a basic test case
    • module() method / Understanding the QUnit module (), setup (), and teardown () methods
    • setup() method / Understanding the QUnit module (), setup (), and teardown () methods
    • teardown() method / Understanding the QUnit module (), setup (), and teardown () methods
    • Backbone components, testing / Testing Backbone.js components with QUnit

R

  • relational data model
    • about / Understanding the relational data model
  • remove() method / Avoiding memory leaks with the listenTo() method
  • render() function / Displaying model data with templates
  • require.config() method / Configuring dependencies
  • Require.js
    • URL / Working with Asynchronous Module Definition
    • adding, to application / Adding Require.js to your project
    • properties / Configuring dependencies
  • requirejs-tpl plugin
    • used, for precompiling / Precompiling with the requirejs-tpl plugin
    • about / Precompiling with the requirejs-tpl plugin
  • routers
    • working with / Working with routers
    • best practices / Best practices for working with routers

S

  • save() method
    • about / Updating a model
    / Performing data operations with collections
  • serialize() method / Using Layout Manager
  • set() method / Fetching data from the server
  • setModel() method / Using Layout Manager
  • setup() method, QUnit
    • about / Understanding the QUnit module (), setup (), and teardown () methods
  • setView() method / Using Layout Manager
  • shim config
    • about / Configuring dependencies
  • showChangedAddress() method / Partially updating a view
  • showUserName() method / Understanding nested views
  • sort() method / Sorting a collection
  • sSpies
    • testing with / Testing with spies
  • startDrag() method / Using curry to combine a function and arguments
  • stubs
    • testing with / Testing with stubs
  • subrouter
    • about / Subrouting – a key to organizing complex apps
    • all-in-one router / The all-in-one router
    • base router / The base router
    • users module router / The Users module router
  • subrouting
    • about / Subrouting – a key to organizing complex apps
  • subviews
    • about / Knowing when to use subviews
    • using / Knowing when to use subviews
    • multiple DOM reflow, avoiding / Avoiding multiple DOM reflow
    • parent views, re-rendering / Re-rendering parent views
    • parent views, removing / Removing parent views

T

  • teardown() method, QUnit
    • about / Understanding the QUnit module (), setup (), and teardown () methods
  • template compilation
    • about / Precompiling templates
  • template helper functions
    • using / Using template helper functions
  • templates, views
    • about / Working with templates
    • storing, in HTML file / Storing templates in an HTML file
    • storing, in JavaScript file / Storing templates in a JavaScript file
    • precompiling / Precompiling templates
    • evaluation, avoiding / Avoiding evaluation in templates
    • template helper functions, using / Using template helper functions
  • Test Driven Development (TDD) / Understanding why unit testing is important
  • toJSON() method
    • about / Basic usage of models
  • tutorials
    • about / Tutorials

U

  • Underscore.js
    • URL / Using Underscore.js
    • about / Using Underscore.js
    • functions / Using Underscore.js
    • benefits / Using Underscore.js
  • unit testing
    • benefits / Understanding why unit testing is important
    • about / Unit testing
  • users module router
    • about / The Users module router
  • UserView class / Understanding the el property
  • utility methods
    • about / Understanding other important features

V

  • validate() method
    • about / Validating the data
  • view events
    • listening to / Listening to view events
  • view management
    • about / Understanding view management

W

  • Where() method / Filtering a collection
  • where() method / Performing basic filtering
lock icon The rest of the chapter is locked
arrow left Previous Section
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $24.99/month. Cancel anytime