Difference between Backbone.Layout.extend and Backbone.view.extend

So, I have this new project that has this line in all views.

Backbone.Layout.extend({ /*...*/ })

      

But when I look at the documentation for Backbone and other tutorials it has

Backbone.View.extend({ /*...*/ })

      

Also, all representations are functions of initialize

, serialize

, afterRender

. I tried searching for it but didn't find anything useful.

+3


source to share


1 answer


Your project uses backbone.layoutmanager

Provides a logical framework for assembling layouts and views in Backbone. Designed to adapt and customize for painless integration. Well tested with full code coverage in both browser and Node.js environments.

Looking at the source of this library , we can see that it is just specialized Backbone.View

.

var LayoutManager = Backbone.View.extend({ // line 53
// ...
});
// ...
// Expose through Backbone object.
Backbone.Layout = LayoutManager; // line 955

      



It adds these methods and properties :

  • afterRender

  • cleanup

  • getView

  • getViews

  • insertView

  • insertViews

  • removeView

  • renderViews

  • setView

  • setViews

  • then

  • useRAF

  • serialize

    (not listed on wiki)

The default function initialize

is used in the Backbone view, it is empty and is intended to be overridden with custom initialization code.

To better understand what's going on in the project, look at the dependencies it loads (files .js

included in tags <script>

in HTML).

+2


source







All Articles