Tag Archives: RequiresJS

Inheriting Views in BackboneJS

via Inheriting Views in BackboneJS – WebSpeaks.

BackboneJS provides an awesome technique for structuring our application code. And RequiresJS makes it modular. So we can write separate modules for each HTML block on our page. But sometimes separate views in our application have similar kind of functionalities. Most of the functions in both views are common. So it is not at all recommended to write that common code in both of the Backbone views. It will make application difficult to maintain. To avoid this we can implement a simple OOP technique known as ‘Inheritance’. We can inherit one of the view in other view. So the child view will have all the functionalities of the parent view. Additionally we can add our own methods in the child view or we can override the parent methods in child view by creating methods with same name.