Book Image

Backbone.js Cookbook

By : Vadim Mirgorod
Book Image

Backbone.js Cookbook

By: Vadim Mirgorod

Overview of this book

<p>There is no doubt that the superior rendering power of HTML5, thin-to-thick client transition and REST style communication created a new era in web development, replacing the outdated approach based on browser plugin technologies. Backbone.js allows developers to write lightweight, modular, and scalable JavaScript applications.<br /><br />Backbone.js Cookbook contains a series of recipes that provide practical, step-by-step solutions to the problems that may occur during frontend application development using an MVC pattern. You will learn how to build Backbone applications utilizing the power of popular Backbone extensions and integrating your app with different third party libraries. You will also learn how to fulfill the requirements of the most challenging tasks.<br /><br />The first chapter of the book introduces you to the MVC paradigm and teaches you how to architect rich Internet applications operating with basic concepts of Backbone.js. During the reading of this book you will learn how to solve challenging problems leveraging Backbone objects such as models, collections, views, routers, and so on.</p> <p><br />You learn how to use forms, layouts, templating engines, and other Backbone extensions, which will help you to complete specific features of your application. You will understand how to bind a model to a DOM element. You will see how perfectly Backbone.js integrates with third party libraries and frameworks such as jQuery, Zepto, Underscore.js, Require.js, Mustache.js, Twitter Bootstrap, jQueryMobile, PhoneGap and many others. This book will guide you in how to optimize and test your applications, create your own Backbone extensions, and share them with the open source community.</p> <p><br />With the help of Backbone.js Cookbook, you will learn everything you need to know to create outstanding rich Internet applications using the JavaScript programming language.</p>
Table of Contents (16 chapters)
Backbone.js Cookbook
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Index

Extending an application with plugins


Backbone's core is small, well-tested, and nicely maintained. However, developers may need additional functionalities to be used by a complex web application. The power of the Backbone framework depends on modularity and flexibility. Existing components can easily be either extended or replaced; thus, many developers create their own plugins.

There are over 100 plugins that can be downloaded and used in your application from https://github.com/documentcloud/backbone/wiki/Extensions,-Plugins,-Resources. In this book, we are going to use some of them, so we need to know how to extend our application with plugins.

How to do it...

If the plugin is a single JavaScript file, simply copy it into the lib folder of the project and include it in index.html.

  <script src="lib/backbone.plugin.js"></script>

Alternatively, if the plugin has been shipped with additional files, such as CSS and images, place all the plugin files in the plugin-name directory under the lib folder, and then include the JS and CSS files in index.html.

Tip

Use Git submodules

If your project is hosted in the Git repository, you can use the Git submodule command to insert a plugin repository inside your project repository. This is very useful if you want to have an easy way to update your project plugins by writing a single git command.

See also

  • The Creating a Backbone.js extension with Grunt recipe in Chapter 8, Special Techniques