Skip to content

Commit 412a7f9

Browse files
committed
Use explanation from airbnb#71
1 parent 7d7c1c7 commit 412a7f9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,9 +1191,9 @@
11911191
11921192
## <a name='events'>Events</a>
11931193
1194-
- When attaching data payloads to events use a hash instead of a raw value.
1195-
1196-
```javascript
1194+
- When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of:
1195+
1196+
```js
11971197
// bad
11981198
$(this).trigger('listingUpdated', listing.id);
11991199
@@ -1202,7 +1202,11 @@
12021202
$(this).on('listingUpdated', function(e, listingId) {
12031203
// do something with listingId
12041204
});
1205+
```
12051206
1207+
prefer:
1208+
1209+
```js
12061210
// good
12071211
$(this).trigger('listingUpdated', { listingId : listing.id });
12081212
@@ -1212,6 +1216,7 @@
12121216
// do something with data.listingId
12131217
});
12141218
```
1219+
12151220
**[[⬆]](#TOC)**
12161221
12171222

0 commit comments

Comments
 (0)