Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Backbone.js only for single page applications?

I'm searching for a simple architecture for my UI that will have some basic javascript functions in like: select all checkbox's, image crop, some pop-ups and some other plugins.

I found this article: Organizing Your Backbone.js Application With Modules

My application is not a SPA (Single Page Application). I want to know if Backbone.js with jQuery will help me even if my application is not a SPA.

like image 475
Acaz Souza Avatar asked Oct 24 '11 13:10

Acaz Souza


People also ask

What is BackboneJS used for?

BackboneJS is a lightweight JavaScript library that allows to develop and structure the client side applications that run in a web browser. It offers MVC framework which abstracts data into models, DOM into views and bind these two using events.

Does anyone still use BackboneJS?

Backbone. Backbone has been around for a long time, but it's still under steady and regular development. It's a good choice if you want a flexible JavaScript framework with a simple model for representing data and getting it into views.

What is the difference between angular and BackboneJS?

AngularJS is a framework. BackboneJS is a lightweight easy-to-use library. AngularJS could be a UI system in JS but based on Typescript. BackboneJS could be a UI system in JS based on MVC (Model View Controller) design pattern.

What is BackboneJS comparable to?

Vue. js, React, AngularJS, Angular 2, and Ember. js are the most popular alternatives and competitors to Backbone. js.


2 Answers

The strength of Backbone is really in its ability to manage many models (even complex ones) and keep the rendered page in sync with their current values. It provides an interface to getter/setter functions so that the changing of a model value (there are many different flavors of "change") will call render on the corresponding view and the page will correctly reflect the underlying models. Furthermore, it provides interfaces to saving, paging, and routing actions on models.

I have used Backbone extensively for both SPA's (where it shines) as well as more traditional, multiple page applications. It has no special support for UI and DOM manipulation, but combined with jQuery/Prototype/Zepto it manages their rendering/manipulation.

Basically, backbone works best to untangle elaborate chains of rendering logic and model updating. If you feel that your application has a lot of view elements that need to stay in sync with models that the client will be updating on the page, Backbone is a wonderful solution. If you just need to select and manipulate DOM elements, it's overkill. jQuery alone can handle that.

like image 101
Erik Hinton Avatar answered Oct 11 '22 12:10

Erik Hinton


Backbone is really not about the things you mentioned, but I wouldn't say it is strictly for single-age apps (SPA) either. I'd say it is for any case where you've got quite complicated pages and it would benefit you to break them up into multiple pieces (for example, several views that all pull data from one model).

However, I would say the strength of Backbone.js is in the SPA realm.

You could probably find some jQuery pieces that answer some of your needs if you're not already using jQuery as part of your app. However, jQuery is all about the parts you mentioned (easy DOM manipulation, popups if you use jQuery UI, etc.) and not about structure or organization.

like image 37
John Munsch Avatar answered Oct 11 '22 11:10

John Munsch