Skip to content

Commit 8f90653

Browse files
committed
Update Unicorn.call documentation.
1 parent 225cb80 commit 8f90653

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

docs/source/actions.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,27 @@ Validates the component.
288288

289289
## Calling methods
290290

291-
Sometimes you need to trigger a method on a component from regular JavaScript. That is possible with `Unicorn.call()`. It can be called from anywhere on the page.
291+
Sometimes you need to trigger a method on a component from regular JavaScript. That is possible with `Unicorn.call()`. The first argument is the name (or key) of the component and the second argument is the name of the method to call.
292292

293293
```html
294-
<!-- index.html -->
294+
<!-- call-with-component-name.html -->
295295
{% unicorn 'hello-world' %}
296296

297297
<button onclick="Unicorn.call('hello-world', 'set_name');">
298298
Set the name from outside the component
299299
</button>
300300
```
301301

302-
Passing arguments is also supported.
302+
```html
303+
<!-- call-with-component-key.html -->
304+
{% unicorn 'hello-world' key='hello-universe' %}
305+
306+
<button onclick="Unicorn.call('hello-universe', 'set_name');">
307+
Set the name from outside the component
308+
</button>
309+
```
310+
311+
Passing arguments the method call is also supported.
303312

304313
```html
305314
<!-- index.html -->

0 commit comments

Comments
 (0)