1bv1aa
Last Updated: February 25, 2016
·
1.038K
· rafaeljesus

Less boilerplate in Backbone Views

First create a BaseView

Picture

Now create a simple backbone view

Picture

You see, you don't need to declare render method in HelloWorldView,

What if you need to render a model data in render method?

Remember we check if serializeData is defined in BaseView

Picture

If you need to render a collection you can easily do it

Picture

If you need to do more stuff inside of render method in BaseView, just create a onRender method on the child view and call it in render method

Picture

If onRender defined in child view just call it

Picture

credits Derick Bailey