From e759e06dec3c5e43b4b5b48999a593ad8979ff64 Mon Sep 17 00:00:00 2001 From: eb-agustin Date: Thu, 29 Sep 2016 18:09:16 -0300 Subject: [PATCH] Marionette views order (#28) --- backbone/README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/backbone/README.md b/backbone/README.md index af13c86..c9a3f42 100644 --- a/backbone/README.md +++ b/backbone/README.md @@ -11,6 +11,7 @@ Backbone and Marionette come with a rich API and also functions provided by [und 0. [Additional plugins](#additional-plugins) 0. [Common terminology](#common-terminology) 0. [File structure](#file-structure) +0. [Ordering](#ordering) 0. [Statics](#statics) 0. [Styling](#styling) 0. [Context](#context) @@ -159,6 +160,38 @@ return MyItemView; **[⬆ back to top](#table-of-contents)** +## Ordering + + - **Outside** `Marionette.View` definition + + 0. `dependencies` requirement + 0. `static` functions + 0. `config` objects + + - Ordering for `Marionette.View`: + + 0. `el` + 0. `template` + 0. `tagName` + 0. `itemView` *Composite View* + 0. `itemViewContainer` *Composite View* + 0. `className` + 0. `ui` + 0. `regions` *Layout* + 0. `events` + 0. `triggers` + 0. `modelEvents` + 0. `initialize` + 0. `templateHelpers` + 0. `onBeforeRender` + 0. `render` + 0. `onRender` + 0. *all the remaining life cycle methods* + 0. *clickHandlers or eventHandlers* + 0. *getter methods* + +**[⬆ back to top](#table-of-contents)** + ## Statics When we write views or models/collections, we tend to enclose all of our functions as methods on the artifact. However, sometimes these methods are really just static helpers that don't need context (i.e. not bound to `this`). In this case, it's better to extract out the function as a private helper, which also simplifies the API exposed by the artifact: @@ -415,7 +448,7 @@ Sinon is a testing utility that we use with our Jasmine Specs for spies, stubs a - The Fake Server allows us to test AJAX requests without a real server and supplying the different responses to test how the app responds. For the API of the Fake Server, see `fake_server.js`. I recommend reading the sinon docs for more information. . Here is an example from our code using spies and the fake server: - + eb = require('eb'); fakeServer = require('es6!require/helpers/tests/fake_server');