Preventing Posting

2 posts, 1 answers
  1. Mattia
    Mattia avatar
    33 posts
    Member since:
    Mar 2015

    Posted 22 Oct 2018 Link to this post

    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

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    646 posts

    Posted 24 Oct 2018 Link to this post

    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.
Back to Top