Event Handling

Event Handling

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.

Adding an Event Handlerkintone.events.on(event, handler())

Registers an event handler.

Function

kintone.events.on(event, handler(event))

Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
event 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(event) Function(Object) Yes The handler that will run when the event is triggered.
All event objects have an event type in their type property.
If the kintone.Promise object* is returned in the handlers of the below events, they will be processed after waiting for the asynchronous operation to finish:

-Record List Events:
  Save Submit Event
  Save Submit Success Event
  Delete Submit Event

-Record Details Events:
  Delete Submit Event
  Proceed Process Event

-Record Create Events:
  Save Submit Event
  Save Submit Success Event

-Record Edit Events:
  Save Submit Event
  Save Submit Success 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

// Run the event handler
var handler = function(event) {
console.log(event);
};
kintone.events.on('app.record.index.show', handler);

Delete a Handler from an Event Typekintone.events.off(event, handler())

Deletes a registered event handler from a specified event type.

Function

kintone.events.off(event, handler(event))

Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
event String or Array of Strings Yes The event type or array of event types, to which the event handler is bound to.
handler(event) Function(Object) Yes The event handler that will be deleted.
Specify the same object that was used when registering the event handler.

Response

True, if any of the event handlers were successfully deleted.
False, if the specified event handlers could not be found.

Sample

// The event handler that will run
var handler = function(event) {
console.log(event);
};
// Delete the event handler
kintone.events.off('app.record.index.show', handler);

Delete all Handlers from an Event Typekintone.events.off()

Deletes all registered event handlers from a specified event type.

Function

kintone.events.off(event)

Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
event String or Array of Strings Yes The event type or array of event types, to which the event handlers are bound to.

Response

True, if any of the event handlers were successfully deleted.
False, if the specified event handlers could not be found.

Sample

kintone.events.off('app.record.index.show');

Delete all Event Handlerskintone.events.off()

Deletes all event handlers.

Function

kintone.events.off()

Response

True, if any of the event handlers were successfully deleted.
False, if the specified event handlers could not be found.

Limitations

  • Can be used on both Desktops and Mobile.
  • Cannot be used on apps attached to bodies of Spaces/Threads/Announcements.
Was this article helpful?
0 out of 0 found this helpful
Comments
  • Avatar
    Nim

    What does the event object look like?

Please sign in to leave a comment.