Book Image

Backbone.js Essentials

By : Jeremy Walker
Book Image

Backbone.js Essentials

By: Jeremy Walker

Overview of this book

<p>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.</p> <p>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.</p>
Table of Contents (20 chapters)
Backbone.js Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Applying parent methods


In order to realize the full power of a class system, however, it's not enough to just define new methods on subclasses; sometimes, we need to combine a method of a parent class with additional logic on a subclass. In traditional object-oriented languages, this is often done by referencing a special super object; but in JavaScript, no such object exists, which means that we have to utilize JavaScript's apply or call methods instead.

For instance, Backbone.Model has a destroy method, but what if we want our Book class to also have its own destroy method? This method might take a number of pages and destroy them (reduce the total number of pages by that amount), but at the same time, we might want to keep the Backbone version around for its original purpose (which is to destroy the server-side version of the Book).

Luckily, because Backbone properly configured our Book class's prototype for us, calling the parent method from the subclass method is fairly straightforward...