marionettejs/backbone.marionette — pull request #396 by janpaul123 (2012-12-20 15:24:12+00:00)
Title: Moving `initialEvents` to `View`

By default `View` should have `initialEvents`, so you can always write your own `initialEvents` function with `super()` (in Coffeescript) to *add* events instead of replacing them.

Use case:
Imagine having an `ItemView`, to which you want to add some events to initialise with. The right place to do this is in initialEvents. So we write:

```
class SomeClass extends Backbone.Marionette.ItemView
initialEvents: ->
@bindTo @model, 'change', @render, @
```

Later on, we refactor it to a `CompositeView`. Now the initialEvents method *overrides* the original one, which we did not intend to do! So we could have written this in the first place:

```
class SomeClass extends Backbone.Marionette.ItemView
initialEvents: ->
super()
@bindTo @model, 'change', @render, @
```

Only, this is not possible, because `ItemView` does not have `initialEvents`. With this pull request we add `initialEvents` to `View`, which makes it easier to refactor code if the above convention is followed.