# Binding to events (6734+)

The platform sends out events when a couple of events are performed. Code can be written to bind to these.

### <span class="mw-headline" id="bkmrk-events-1">Events</span>

- `hide-field`, triggered when the platform hides a field (dependency or hideField-function)
- `show-field`, triggered when the platform shows a field (dependency or showField-function)

### <span class="mw-headline" id="bkmrk-how-to-bind-1">How to bind</span>

```javascript
$("tr").bind("hide-field", function(e) {
    // Do stuff..
})
```

## Custom events

TS implements a couple of custom events, that you can bind your `headers and scripts` to.

### Preparing Submit

When the platform i preparing to submit the form, first it fires the event `TS_PrepareSubmitForm` on `#TempusServaPage`.  
You can bind to this event like this:

```javascript
$('#TempusServaPage').on('TS_PrepareSubmitForm', () => {
  console.log('Preparing submit!')
})
```

### Dynamic reload of fields

If the policy `reloadParentFieldsOnClose` is enabled (as of version 11355) when a child-record is submittet, the parent record i no longer reloaded, instead a reload is performed in the background, and the child-fields are replaced.  
Once this task is performed the platform fires the event `TS_RefreshFieldsFromServer` on `#TempusServaPage`.  
You can bind to this event like this:

```javascript
$('#TempusServaPage').on('TS_RefreshFieldsFromServer', () => {
  console.log('child was submitted!')
})
```