I'm confused about what code I should instantiate directly in Backbone.js. Should I create a generic object App
that instantiates my views? Should I instantiate an App View
that instantiates all the other views on the page and coordinates everything? Should I create views, models and collections and attach them to the window
?
Also, are controllers even necessary? So far I'm not finding any use for them and they are missing from many of the examples out there. Should I instantiate a controller and have it create the other objects as I do in other languages' MVC frameworks?
My guess is I am free to do what I want but I would prefer some advice from somebody who has used it quite a lot.
In backbone. js, there are 7 modules HTTP request, Router, View, Events, Model, and Collection. Whenever a user makes a request it is directed to the router and in response to these requests, a user interface is displayed at the user end which is known as Views.
js view class to create a custom view. Syntax: Backbone. View.
Backbone. js allows developers to develop one page applications and front-end much easier and better using JavaScript functions. Backbone provides different types of building blocks like models, views, events, routers and collections for assembling client side web applications.
js. Backbone. js developers usually focus on the front-end aspect of web applications, but also must have basic understanding of some back-end technologies, since their responsibility includes the integration of APIs and resources with front-end elements as provided by the back-end developers and engineers.
Controllers are useful for managing the hashbang URL.
If you don't have multiple pages, states you want to save or want to use the back and forwards buttons then controllers have no use.
Most examples of backbone I've seen have a AppView class that manages views and collections.
See the Annotated Example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With