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
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,14 +160,21 @@ class HelloWorldElement extends HTMLElement {
160
160
161
161
### Binding dynamically added actions
162
162
163
-
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.
164
-
165
-
You can provide the element you'd like to observe as a first argument which will default to `document`.
163
+
Catalyst automatically listens for elements that are dynamically injected into the DOM, and will bind any element's `data-action` attributes. It does this by calling `listenForBind(controller.ownerDocument)`. If for some reason you need to observe other documents (such as mutations within an iframe), then you can call the `listenForBind` manually, passing a `Node` to listen to DOM mutations on.
166
164
167
165
Batch processing binds events in small batches to maintain UI stability (using `requestAnimationFrame` behind the scenes).
168
166
169
167
```js
170
168
import {listenForBind} from'@github/catalyst'
171
169
172
-
listenForBind(document)
170
+
@controller
171
+
classHelloWorldElementextendsHTMLElement {
172
+
@target iframe:HTMLIFrameElement
173
+
174
+
connectedCallback() {
175
+
// listenForBind(this.ownerDocument) is automatically called.
0 commit comments