File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1
1
import Ember from 'ember' ;
2
2
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 will be unbound. 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.incrementCount)}}>first</div>
29
+ <div {{did-insert (action this.incrementCount)}}>second</div>
30
+
31
+ <p>{{this.count}} elements were rendered</p>
32
+ ```
33
+
34
+ ```js
35
+ export default Component.extend({
36
+ @tracked count = 0;
37
+
38
+ incrementCount() {
39
+ this.count++;
40
+ }
41
+ });
42
+ ```
43
+
44
+ @method did-insert
45
+ @public
46
+ */
3
47
export default Ember . _setModifierManager (
4
48
( ) => ( {
5
49
createModifier ( ) { } ,
You can’t perform that action at this time.
0 commit comments