How to handle events in Clerk.js.

Events enable you to hook in to the rendering process of Clerk.js.

after-callRight after the response has been returned from the API.
before-renderRight before the rendering process begins.
after-renderRight after the rendering process has occurred.
on-errorOn any error.

Example use of an event-handler:

<span class="clerk" data-template="@popular-products" data-after-render="logProducts"></span>

  function logProducts(data) {

Each event calls the event handler with an event object with the following form:

  api: "recommendations/popular",
  args: {
    key: "your_api_key",
    limit: 10,
  template: "#clerk-product-template",
  target: "#popular-products",
  response: {
    "status": "ok",
    "result": [123, 456, ... 890],
    "product_data": [{"id":123,"name":"Lightsaber",... "price":22.00}],...
  api: ... ,
  args: ... ,
  template: ... ,
  target: ... ,
  response: ...
apiThe API endpoint of the request.
argsThe parameters of the request.
templateThe template to be used.
targetThe target where the products will be rendered.
responseThe full response object from the API.