# addEventListener

### Parameters

1. Events
2. Control Id (optional)
   * If the event is control specific (e.g. click on a buttton), this has to be the control id of that button
3. Function
   * The code that should be executed in case of this event
   * The first parameter is the brixxApi

### Example Usages

```javascript
   brixxApi.addEventListener("onRecordSaved", function (brixxApi, eventArgs) {
      alert("Record saved in " + brixxApi.appName);
   });
```

```javascript
   brixxApi.addEventListener("onClick", "myButton", function (/*event parameters are optional*/) {
      alert("Button clicked");
   });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/addeventlistener.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
