Backbone.Marionette.js: A Gentle Introduction
Backbone.Marionette.js: A Gentle Introduction
Build a Marionette.js app, one step at a time
About the Book
If you're interested in getting the latest and greatest in Marionette, help by making a book on v3 a reality here.
I might be writing a new book covering v3. I don't know whether there will be enough interest to warrant it, or when it will be ready, so you'll probably still want to pick this one up: current readers will get a major discount on the new book when it ships.
The book is up to date for Marionette 2.3. In addition, you also receive the book covering Marionette 1.7.4.
Given the popularity of the short tutorials on Marionette.js I've published on my blog, I've decided to write a book on Marionette.js. The style is the same as in my tutorials: explaining concepts step by step, so you fully understand what is going on, and why we're doing it. This book has great feedback, including Marionette.js' creator (Derick Bailey):
Seriously, why haven’t you bought [this book] yet?— Backbone.Marionette (@marionettejs)May 29, 2013
And from Derick's foreword:
This is the book that I wanted to write, but never had time to write. It is a complete and thorough introduction to building scalable applications with Marionette.js. Better still, it advocates and demonstrates the same patterns and principles that I use in my own applications. You owe it to yourself to work through all of the exercises in this book, even if you are a seasoned Backbone and Marionette developer. David has done a wonderful job of breaking down the architecture of large Marionette applications, lighting the path for each step of the journey.
I've worked really hard to make this a great resource for learning Marionette the "right" way, even for total beginners: you'll gradually discover Marionette components, along with when/why to use them, and how to structure/refactor your code so it stays manageable even for large applications. After you've made it through the book, you'll be comfortable writing a Marionette application on your own.
Exercises covering the basic concepts are included (with solutions), so you can check for yourself if you've properly understood the functionality that was covered in a given chapter.
Grab your own copy today!
What You'll Learn
How to build this application step by step, including:
- Structuring your large apps with modules to manage complexity
- Using regions and layouts to segment your displays and make them manageable
- Managing forms, along with error display
- Handling data latency and displaying loading views
- Filtering collections and updating views, matching URL fragments to filtering criteria
- Extending the Marionette framework to clean up your code and make your life easier
- Using mixins to add common functionality to objects
- Defining your own view classes to extend from, sharing common behavior
- Implementing Backbone routing properly
- Swapping sub-applications
- Managing menu entries with non-persisted models
And much more! All of this will be covered step by step so you fully understand how and why code is being added, removed, or refactored.
Who This Book is For
What Readers Are Saying
I've included some sample reader feedback below, but if you need more convincing take a look at the feedback page.
[...] Back in my commercial programming days, I went on lots of courses and they always asked you at the end whether the course would help you in your day to day work. Largely they were of some help but with David’s book I can wholeheartedly say it was an immense help. Pitched at the perfect level it took a grisly middleware digital plumber out of his binary cave and into the vast open plains of the client landscape. I thoroughly enjoyed it! -- Alistair Young
This book has been invaluable in helping me ramp up my knowledge of developing modern single-page applications. I wish I had found it a few months ago, instead of wasting so much time with short-and-simplistic tutorials that don't help much when you are trying to build a larger application. -- leonardocsouza
Best tutorial book I've ever read on *any* programming subject, never mind one as complicated as this. Thanks for an amazing book. -- Mike Brady
Really great introduction, and nice overview of what is possible architecturally when using backbone. The way David gradually builds up his app is great, and helps drive home conceptually what is going on well. Well worth buying if you are thinking about using Backbone! -- alpower
This was an awesome book for getting started with Marionette. [...] The best part about this book is that it walks you through the concepts starting from small bite size chunks.. slowly refactoring to an elegant system. David, I hope you continue to write books on this subject, you have an awesome style! I give this book 10/10. -- Kirk Quesnelle
Just the right balance of telling you the answers and encouraging you to think for yourself. [...] After an afternoon with this book, I an confident that I will be able to build a solid, maintainable single page application. -- Bastidias
Derick Bailey and Jeremy Ashkenas are giants, and David Sulc is the escalator to their shoulders. I have read both of David's Marionette books at least 3 times. If you have wandered down the the JS rabbit hole this far and found Marionette, this is the tour guide you need to get it right. -- Chet Harrison
Made me realise what I was doing wrong and the proper way to do things. -- marconijr
I'm very glad I bought this book, I only wish I'd bought it sooner - it would have saved me weeks. David does a great job explaining how to use Marionette, and also why you should use it in one way or another. [...] I find that this is a book I keep coming back to for clean ways to architect my own code. The end result for me? I have taken a hideous, inflexible and inefficient survey application and made it pretty and easy and fast. Happy times. -- Christo Fogelberg
New to Backbone and far from a JS expert. This book was great for someone like me - not overwhelming and really helpful to conceptualize the framework. -- keeper2597
I had no experience in web development and had to develop a fairly complex complex single page app. [...] This book has helped me to develop a well-structured, easy to maintain and extendable app in no time. I can't wait to read your more advanced book on Marionette. I'd recommend this book to anyone interested in single page apps development. -- Alberto M Valdunciel
Really great introduction, David. I'm an experience Backbone developer (a couple large apps under my belt), but I was having trouble seeing how all the Marionette pieces fit together. Your introduction connected the dots in a very intuitive way. -- Scott Riding
Great book. Ordered it because we started building a complex frontend application with Backbone Marionette but didnt have proper understanding of it. Now everything is clear, we are having insane speed developing the application. Planning to write a blog post about how to learn Backbone Marionette, I'm 100% sure that this book will be mentioned among the first ones. -- Blacksonic
David's writing style makes it seem like you have a super-calm coach in the room with you. Highly recommended. -- Adrian Goins
- Foreword from Derick Bailey
- Cover Credits
- Who This Book is For
Following Along with Git
- Jumping in for Advanced Readers
- Asset Organization
- Getting Our Assets
Displaying a Static View
- Dynamically Specifying a View Template
- Specifying Other View Attributes
- Implementing Region Management
Displaying a Model
- Using Model Defaults
- Introducing Events
Displaying a Collection of Models
- Introducing the CollectionView
- Listing our Contacts with a CollectionView
- Sorting a Collection
Structuring Code with Modules
- Extracting our App Definition
- Moving Contacts to the Entities Module
- Creating a Module for the ContactsApp Sub-Application
- Moving the App Initialization Handler
- Dealing with Templates
Using a CompositeView
- Using Events
Events, Bubbling, and TriggerMethod
- Communicating via Events
- Animating the Removed ItemView
- Introducing TriggerMethod
Displaying Contacts in Dedicated Views
- Wiring up the Show Event
- The ContactsApp.Show Sub-Module
- How to Think About Routing
- Adding a Router to ContactsApp
- Routing Helpers
- DRYing up Routing with Events
- Adding a Show Route
- Implementing a View for Nonexistent Contacts
Dealing with Persisted Data
- Adding a Location to our Entities
- Configuring our Entities to use Web Storage
- Loading our Contacts Collection
- Loading a Single Contact
- Deleting a Contact
Handling Data Latency
- Delaying our Contact Fetch
- Using jQuery Deferreds
- Displaying a Loading View
- Passing Parameters to Views and SerializeData
Managing Forms: Editing a Contact
- Saving the Modified Contact
- Validating Data
Displaying a Modal Window
- Using jQuery UI
- Adding the Edit Link
- Implementing Modal Functionality
- Handling the Modal Form Data
- Subdividing Complex Views with Layouts
Extending from Base Views
- Some Cleanup
Managing Dialogs with a Dedicated Region
- Customizing onRender
- Implementing an Empty View
- Optional Routes and Query Strings
The ‘About’ Sub-Application
- Coding the Sub-App
The ‘Header’ Sub-Application
- Setting up the Models
- Adding Templates and Views
- Implementing the Controller and Sub-Application
- Navigating with the Brand
- Highlighting the Active Header
- Handling Menu Clicks
- Keeping in Touch
- Other Books I’ve Written
- Bonus Chapter
- Using the Contact Manager Application
- Adapting the Application
- Module Architecture
- Displaying a Contact With No Phone Number
- Sorting a Collection
- Declaring a Template Sub-Module
- Building your own CompositeView
- Displaying the Contents of a Clicked Table Cell
- Event Bubbling from Child Views
- Getting Back to the Contacts List
Overriding Marionette’s Template Loader
- Declaring a Template Sub-Module
- Tackling the Template Loader
- Specifying our new Template
- Extending Marionette
Using Web Storage for Persistence
- Implementation Strategy
- Adding to the Entities Module
- Proxying the Constructor
- Using a Mixin with Underscore
- Determining the Storage Key
- Using a Storage Cache
- Calling the Constructor with Apply
- Creating a FilteredCollection
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
C++ Best PracticesJason Turner
Level up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
OpenIntro StatisticsDavid Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntro
A complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Functional Design and ArchitectureAlexander Granin
Software Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
Atomic KotlinBruce Eckel and Svetlana Isakova
For both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
C++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
Introductory Statistics with Randomization and SimulationMine Cetinkaya-Rundel, Christopher Barr, OpenIntro, and David Diez
A complete foundation for Statistics, also serving as a foundation for Data Science, that introduces inference using randomization and simulation while covering traditional methods.
Leanpub revenue supports OpenIntro, so we can provide free desk copies to teachers interested in using our books in the classroom.
More resources: openintro.org.
Java OOP Done RightAlan Mellor
Object Oriented Programming is still a great way to create clean, maintainable code. But only if you use it right.
This book gives you 25 years of OO best practice, ready to use.
You'll learn to design objects behaviour-first, use TDD to help, then confidently apply Design Patterns, SOLID principles and Refactoring to make clean, crafted code.
Ansible for DevOpsJeff Geerling
Ansible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Composing SoftwareEric Elliott
All software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
Cloud StrategyGregor Hohpe
“Strategy is the difference between making a wish and making it come true.” A successful migration to the cloud shouldn’t be driven by wishes, but guided by a sound strategy, frameworks, and decision models. This book tells you how—without becoming superficial nor getting lost in technology and product details.
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before...
CCIE Service Provider Ultimate Study Bundle
2 BooksPiotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification...
Cisco CCNA 200-301 Complet
4 BooksCe lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301.
CCDE Practical Studies (All labs)
3 BooksCCDE lab
Modern Management Made Easy
3 BooksRead all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization.
The Future of Digital Health
6 BooksWe put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer...
Modern C++ by Nicolai Josuttis
Django for Beginners/APIs/Professionals
"The C++ Standard Library" and "Concurrency with Modern C++"
2 BooksGet my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library...
Linux Administration Complet
4 BooksCe lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité...