Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add documentation for onShow
fixes #551
  • Loading branch information
samccone committed Feb 26, 2014
1 parent ac6569d commit cd5288a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/marionette.view.md
Expand Up @@ -12,6 +12,7 @@ behaviors that are shared across all views.
## Documentation Index

* [Binding To View Events](#binding-to-view-events)
* [View onShow](#view-onshow)
* [View close](#view-close)
* [View onBeforeClose](#view-onbeforeclose)
* [View "dom:refresh" / onDomRefresh event](#view-domrefresh--ondomrefresh-event)
Expand Down Expand Up @@ -57,6 +58,36 @@ optionally set the context by using `_.bind`.
this.listenTo(this.collection, "add", _.bind(this.reconcileCollection, this.collection));
```

## View onShow

* "show" / `onShow` - Called on the view instance when the view has been rendered and displayed.

This event can be used to react to when a view has been shown via a [region](marionette.region.md).
All `views` that inherit from the base `Marionette.View` class have this functionality. `ItemView`, 'CollectionView', 'CompositeView', 'Layout'

```js
Backbone.Marionette.ItemView.extend({
onShow: function(){
// react to when a view has been shown
}
});
```

A common use case for the `onShow` method is to use it to add children views.

```js
var LayoutView = Backbone.Marionette.Layout.extend({
regions: {
Header: 'header',
Section: 'section'
},
onShow: function() {
this.Header.show(new Header());
this.Section.show(new Section());
}
});
```

## View close

View implements a `close` method, which is called by the region
Expand Down

0 comments on commit cd5288a

Please sign in to comment.