JavaScript/jQuery Chat - editing

Configures editing.

Type:

Object

View Demo

NOTE
  • Before allowing a user to update and delete messages, make sure that your data source supports these actions.
  • Set the Store's key property to "id" to ensure editing functions correctly.
index.js
  • $('#chat').dxChat({
  • dataSource: initialMessages,
  • editing: {
  • allowUpdating: true,
  • allowDeleting: true
  • },
  • onMessageEntered({ message }) {
  • e.component.renderMessage(message);
  • },
  • onMessageUpdated(e) {
  • const message = e.message;
  • message.text = e.text;
  • message.isEdited = true;
  • initialMessages[e.message.id] = message;
  • e.component.repaint();
  • },
  • onMessageDeleted(e) {
  • const message = e.message;
  • message.isDeleted = true;
  • initialMessages[e.message.id] = message;
  • e.component.repaint();
  • },
  • });

allowDeleting

Specifies whether a user can delete messages. Called for each message when defined as a function.

Type:

Boolean

|

Function

Function parameters:
options:

Object

Information about the current message.

Object structure:
Name Type Description
component

dxChat

Chat's instance.

message

Message

Message data.

component:

dxChat

Chat's instance.

message:

Message

Message data.

Return Value:

Boolean

true if the message can be deleted; otherwise false.

Default Value: false

If false, no messages can be deleted. If true, only the current user can delete their messages.

allowUpdating

Specifies whether a user can update messages. Called for each message when defined as a function.

Type:

Boolean

|

Function

Function parameters:
options:

Object

Information about the current message.

Object structure:
Name Type Description
component

dxChat

Chat's instance.

message

Message

Message data.

component:

dxChat

Chat's instance.

message:

Message

Message data.

Return Value:

Boolean

true if the message can be updated; otherwise false.

Default Value: false

If false, no messages can be edited. If true, only the current user can edit their messages.