Drupal 8 with Backbone.js

I have just completed my first Backbone.js app with Drupal 8. It has been a new experience for me. I needed to build a solution that related to the views filters and content listings. As you probably know, Drupal 8 content listings are powered by views now, which allows users to configure filters and add fields to the table of content. So, when different editors work with different filters and columns, they want to hide some and show only those that they need. My task was to build a solution that allowed each user with permissions to select, which filters and which table columns they want to see.

I instantly understood, that it needed to be a javascript app. All non-javascript solutions I thought of were very messy and user-unfriendly. Hence, a javascript app was needed, with some good support of collections of elements. And we already have a framework in Drupal 8 core, that does that. Backbone.js is already used in Drupal 8 core to add app-like functionality to pages, starting from refreshless editing and ending with the contextual links. Backbone.js is not the newest of the frameworks that do that, and there are probably more powerful frameworks, like Angular.js and Vue.js. However, Angular seemed to be an overkill, and Vue.js seemed to only be gaining momentum. I would probably go with Vue.js if Backbone was not already in Drupal 8 core.

Backbone.js is simple once you come to know it's concepts. Models that can be grouped into collections and can synchronize with the server, and views (in mvc sense, not in a Drupal module sense). I never used routing in this project, didn't have to. My overall impression of Drupal 8 with Backbone.js are very positive. Drupal's and Drupal Views module out-of-the-box allowed me to integrate with Backbone.js without changing anything about the the markup and theming. The only challenge was the fact that reloading a Drupal view form via ajax changed the form id's. That was not fatal, though, because Drupal 8's ajax forms use a predictable id's naming patterns in forms id's generation.

I completed the task with a strong impression, that Drupal 8 is a powerful beast, that plays well with the modern technologies, and allows you to achieve more with it that Drupal 7 did.