Skip to content

Commit afbad69

Browse files
committed
Added {{did-insert}} API docs
1 parent df97d70 commit afbad69

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

addon/modifiers/did-insert.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
import Ember from 'ember';
22

3+
/**
4+
The `{{did-insert}}` element modifier is activated when an element is
5+
inserted into the DOM.
6+
7+
In this example, the `fadeIn` function receives the `div` DOM element as its
8+
first argument and is executed after the element is inserted into the DOM.
9+
10+
```handlebars
11+
<div {{did-insert this.fadeIn}} class="alert">
12+
{{yield}}
13+
</div>
14+
```
15+
16+
```js
17+
export default Component.extend({
18+
fadeIn(element) {
19+
element.classList.add('fade-in');
20+
}
21+
});
22+
```
23+
24+
By default, the executed function won't be bound. If you would like to access
25+
the component context in your function, use the `action` helper as follows:
26+
27+
```handlebars
28+
<div {{did-insert (action this.fadeIn)}} class="alert">
29+
{{yield}}
30+
</div>
31+
```
32+
33+
@method did-insert
34+
@public
35+
*/
336
export default Ember._setModifierManager(
437
() => ({
538
createModifier() {},

0 commit comments

Comments
 (0)