Skip to content

Commit

Permalink
add js api events
Browse files Browse the repository at this point in the history
  • Loading branch information
atanas-dev committed Aug 2, 2017
1 parent 752a37b commit cb31973
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions documentation/40-advanced-topics/50-javascript-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,37 @@ Add a group to a complex field. `groupName` is optional when the field does not

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

### API jQuery Events

`'carbonFields.apiLoaded'`

Triggered when the Carbon Fields' JS API is loaded.

| Parameter | Description |
| --------- | ---------------------------------------------------------- |
| `event` | Event Object |
| `api` | API object which is used to communicate with Carbon Fields |

`'carbonFields.fieldUpdated'`

Triggered when a field's value changes.

| Parameter | Description |
| --------------- | ---------------------------------- |
| `event` | Event Object |
| `fieldName` | Name of the field that was updated |

`'carbonFields.validateField'`

Triggered when a field is being validated.
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).

| Parameter | Description |
| --------------- | ------------------------------------------------- |
| `event` | Event Object |
| `fieldName` | Name of the field that is being validated |
| `error` | The current error message for the field or `null` |

### Examples

##### Getting the API object instance
Expand Down

0 comments on commit cb31973

Please sign in to comment.