marionettejs/backbone.marionette — pull request #1159 by amitsnyderman (2014-04-13 18:19:00+00:00)
Title: Allow for behaviors to have behavior

Gonna put a behavior on your behavior. We have a particular use-case that would benefit from this: two behaviors – `Modal` and `HotKeys` – where a modal needs the hotkeys behavior.

This definitely needs more tests but it's unclear how tightly bound a child behavior should be to the root view (i.e. do we want to support `modelEvents`, etc?). There are two ways to think of the problem: 1) recursively bound to the parent view or behavior (as implemented) or 2) unwrapped and explicitly bound to the view.

An alternative implementation for (2) involves changing the `Marionette.Behaviors` constructor to accept both the view and list of behaviors, allowing us to unfold the recursion, e.g.:

```js
_.each(behaviors, function(b) {
if (_.isObject(b.behaviors)) {
new Marionette.Behaviors(view, b.behaviors);
}
});
```

This also does not address the possibility of circular references.