You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_guide/actions.md
+15-3Lines changed: 15 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,14 +144,26 @@ If you're using decorators, then the `@controller` decorator automatically handl
144
144
145
145
If you're not using decorators, then you'll need to call `bind(this)` somewhere inside of `connectedCallback()`.
146
146
147
-
```
147
+
```js
148
148
import {bind} from'@github/catalyst'
149
149
150
150
classHelloWorldElementextendsHTMLElement {
151
-
152
151
connectedCallback() {
153
152
bind(this)
154
153
}
155
-
156
154
}
157
155
```
156
+
157
+
### Binding dynamically added actions
158
+
159
+
Catalyst doesn't automatically bind actions to elements that are dynamically injected into the DOM. If you need to dynamically inject actions (for example you're injecting HTML via AJAX) you can call the `listenForBind` function to set up a observer that will bind actions when they are added to a controller.
160
+
161
+
You can provide the element you'd like to observe as a first argument and the number of items to process in a batch as a second argument. Those arguments default to `document` and `30` respectively.
162
+
163
+
Batch processing binds events in small batches to maintain UI stability (using `requestAnimationFrame` behind the scenes). We recommend the default of `30` as a sensible default, but you may find changing this number helps depending on your requirements.
0 commit comments