Events

JavaScript events can be used to trigger a function when something happens, like when a user clicks on an HTML element.

Currently, the following events are available:

brf_live_update

With Pro Forms, you can specify Live Update Selectors to inject the value coming from the database to the DOM. Whenever a value changes trough Live Update, the brf_live_update event is triggered.

document.addEventListener("brf_live_update", function (event) {
  console.log("Live Update triggered for: " + event.detail.selector);
});

The event.detail object contains various information about the live update event. Also, you can modify the object to change the value that is injected into the DOM.

To do this, you can use the following code:

document.addEventListener("brf_live_update", function (event) {
  event.detail.newValue = "New value";
});

If needed, you could also modify the selector that is used to inject the value into the DOM:

document.addEventListener("brf_live_update", function (event) {
  event.detail.newTarget = "#my-selector";
});