Event Handling

Contents

Overview

On this page, we introduce how handlers can be attached to various Kintone events. The different types of Kintone events are listed in the side menu.

Register Event Handlers - kintone.events.on(type, handler)

Registers an event handler.

Function

kintone.events.on(type, handler)

Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
type A string or an array of strings Yes The event type or array of event types, to which the event handler will bind to.
handler Function(Object) Yes The handler that will run when the event is triggered.
All event objects have an event type in their type property.
By returning a kintone.Promise object* in the event handler, the next operations can be processed after waiting for asynchronous processes in the event handler to finish:

- Record List Events:
  - Onload Event
  - Inline Edit Event
  - Save Submit Event
  - Save Submit Success Event
  - Delete Submit Event
- Record Details Events:
  - Onload event
  - Delete Submit Event
  - Proceed Process Event
- Record Create Events:
  - Onload Event
  - Save Submit Event
  - Save Submit Success Event
- Record Edit Events:
  - Save Submit Event
  - Save Submit Success Event
  - Onload Event
- Record Print Events:
  - Onload Event
- Graph Display Events:
  - Onload Event
- Portal Display Events:
  - Onload Event

*A kintone.Promise object is an object that holds a “then” method.
- Reference(External site):
  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

Response

None

Sample

1
2
3
4
5
6
var handler = function(event) {
  console.log(event);
};
kintone.events.on('app.record.index.show', handler);

kintone.events.on(['app.record.detail.show', 'app.record.edit.show'], handler);

Remove Event Handlers - kintone.events.off(type, handler)

Removes event handlers from the specified event type(s).

Function

kintone.events.off(type, handler)

Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
type String or Array of Strings The event type(s) to which the event handler is bound to.
handler Function(Object) The handler that will be removed from the specified event type(s).
If no value is set for this parameter, all event handlers will be removed from the specified event type(s).
If no values are set for both the type and handler parameter, then all event handlers will be removed from all event types.

Response

True, if any event handlers were removed.
False, if no event handlers were removed.

Sample

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
var handler = function(event) {
  console.log(event);
};
kintone.events.on('app.record.index.show', handler);

// Option 1: Remove the specified handler from the specified event type
kintone.events.off('app.record.index.show', handler);

// Option 2: Remove all handlers from the specified event type
kintone.events.off('app.record.index.show');

// Option 3: Remove all handlers from all event types
kintone.events.off();

Limitations