===================================== Part 5 - More Fun with Broadcasts ===================================== Removing Chat Messages ====================== Let's continue to build on this basic chat application by allowing the user to remove messages. Let's walk through the steps to accomplish this: * Add links to the `message` component template to remove the message. Add a message_id to each list item so Turbo knows which message to delete. * Create a view that deletes the message. * Add an ``on_delete`` method to the ModelBroadcast. Tell the room subscribers to remove the message div by ID. Start by adding a unique id to each ``
  • `` element. Then add a link to remove that message in the template. .. code-block:: html :caption: templates/chat/components/message.html
  • {{message.created_at}}: {{message.text}} [Remove]
  • This new delete link with redirect the entire page. To only send a request to the message_delete url, the links need to be inside a turbo frame. Wrap the `