Skip to content

Commit cb31973

Browse files
committed
add js api events
1 parent 752a37b commit cb31973

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

documentation/40-advanced-topics/50-javascript-api.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,37 @@ Add a group to a complex field. `groupName` is optional when the field does not
2424

2525
Remove a group from a complex field by it's index.
2626

27+
### API jQuery Events
28+
29+
`'carbonFields.apiLoaded'`
30+
31+
Triggered when the Carbon Fields' JS API is loaded.
32+
33+
| Parameter | Description |
34+
| --------- | ---------------------------------------------------------- |
35+
| `event` | Event Object |
36+
| `api` | API object which is used to communicate with Carbon Fields |
37+
38+
`'carbonFields.fieldUpdated'`
39+
40+
Triggered when a field's value changes.
41+
42+
| Parameter | Description |
43+
| --------------- | ---------------------------------- |
44+
| `event` | Event Object |
45+
| `fieldName` | Name of the field that was updated |
46+
47+
`'carbonFields.validateField'`
48+
49+
Triggered when a field is being validated.
50+
This event actually behaves like a WordPress filter - you have to return a value. This enables you to define your own custom validation and error messages (an example can be found below).
51+
52+
| Parameter | Description |
53+
| --------------- | ------------------------------------------------- |
54+
| `event` | Event Object |
55+
| `fieldName` | Name of the field that is being validated |
56+
| `error` | The current error message for the field or `null` |
57+
2758
### Examples
2859

2960
##### Getting the API object instance

0 commit comments

Comments
 (0)