This is a migrated thread and some comments may be shown as answers.

Preventing Posting

1 Answer 66 Views
Chat
This is a migrated thread and some comments may be shown as answers.
Mattia
Top achievements
Rank 1
Mattia asked on 22 Oct 2018, 09:24 AM

Hello, I'm trying to prevent chat posting, I mean when user click send button (or type keybord enter) I want in some cases to prevent the post of the message.
Something like this is not working (the message is posted in chat)

$("#chat").kendoChat({
    post: function(e) {
        e.preventDefault();       
    }
});

Is that a bug? Or there is a different approach to accomplish this task?
Thanks,
Mattia

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 24 Oct 2018, 08:11 AM
Hello Mattia,

Currently, the Chat post and sendMessage events cannot be prevented. I have logged an enhancement issue in the official Kendo UI GitHub repository and you can start tracking its progress from here(#4609).

One thing that you can try to achieve similar result is to subscribe to the sendMessage event and conditionally set the text and message box to empty. In this way, no message will be rendered in the Chat view:
sendMessage: function(e) {
  if(e.text == "not allowed") {
    e.text = "";
    e.sender.messageBox.input.val("");
  }
}

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Chat
Asked by
Mattia
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or