Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add documentation for onShow

fixes #551
  • Loading branch information...
commit cd5288a065aff436a4b8c87490d15ccfc4ebef36 1 parent ac6569d
@samccone samccone authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 docs/marionette.view.md
View
31 docs/marionette.view.md
@@ -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)
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.