Skip to content

Commit 190c394

Browse files
author
Derick Bailey
committed
updating documented events for the collection view
1 parent 3aac568 commit 190c394

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

docs/marionette.collectionview.md

+41-13
Original file line numberDiff line numberDiff line change
@@ -182,28 +182,32 @@ Backbone.Marionette.CollectionView.extend({
182182
## CollectionView Events
183183

184184
There are several events that will be triggered during the life
185-
of a collection view. These are intended to be handled from code
186-
external to the view.
185+
of a collection view. Each of these events is called with the
186+
[Marionette.triggerMethod](./marionette.functions.md) function,
187+
which calls a corresponding "on{EventName}" method on the
188+
view instance.
187189

188-
### "collection:before:render" event
190+
### "before:render" / onBeforeRender event
189191

190-
Triggers just prior to the view being rendered
192+
193+
Triggers just prior to the view being rendered. Also triggered as
194+
"collection:before:render" / `onCollectionBeforeRender`.
191195

192196
```js
193197
MyView = Backbone.Marionette.CollectionView.extend({...});
194198

195199
var myView = new MyView();
196200

197-
myView.on("collection:before:render", function(){
201+
myView.on("before:render", function(){
198202
alert("the collection view is about to be rendered");
199203
});
200204

201205
myView.render();
202206
```
203207

204-
### "render" / "collection:rendered" event
208+
### "render" / onRender event
205209

206-
A "collection:rendered" event will also be fired. This allows you to
210+
A "collection:rendered" / `onCollectionRendered` event will also be fired. This allows you to
207211
add more than one callback to execute after the view is rendered,
208212
and allows parent views and other parts of the application to
209213
know that the view was rendered.
@@ -224,9 +228,10 @@ myView.on("collection:rendered", function(){
224228
myView.render();
225229
```
226230

227-
### "collection:before:close" event
231+
### "before:close" / onBeforeClose event
228232

229-
Triggered just before closing the view.
233+
Triggered just before closing the view. A "collection:before:close" /
234+
`onCollectionBeforeClose` event will also be fired
230235

231236
```js
232237
MyView = Backbone.Marionette.CollectionView.extend({...});
@@ -240,9 +245,10 @@ myView.on("collection:before:close", function(){
240245
myView.close();
241246
```
242247

243-
### "collection:closed" event
248+
### "closed" / "collection:closed" event
244249

245-
Triggered just after closing the view.
250+
Triggered just after closing the view, both with corresponding
251+
method calls.
246252

247253
```js
248254
MyView = Backbone.Marionette.CollectionView.extend({...});
@@ -256,6 +262,30 @@ myView.on("collection:closed", function(){
256262
myView.close();
257263
```
258264

265+
### "item:added" / onItemAdded
266+
267+
Triggered just after creating a new itemView instance for an
268+
item that was added to the collection, but before the
269+
view is rendered and added to the DOM.
270+
271+
```js
272+
cv.on("item:added", function(viewInstance){
273+
// ...
274+
});
275+
```
276+
277+
### "item:removed" / onItemRemoved
278+
279+
Triggered after an itemView instance has been closed and
280+
removed, when it's item was deleted or removed from the
281+
collection.
282+
283+
```js
284+
cv.on("item:removed", function(viewInstance){
285+
// ...
286+
});
287+
```
288+
259289
### "itemview:\*" event bubbling from child views
260290

261291
When an item view within a collection view triggers an
@@ -388,5 +418,3 @@ Backbone.Marionette.CollectionView.extend({
388418
}
389419
});
390420
```
391-
392-

0 commit comments

Comments
 (0)