1

This is a livechat web app, I need to "refresh" when sending a message, poll works well when using now() outside the foreach (to comprobate that works), but inside the foreach the content and now() does nothing!! I need to refresh the browser to see the changes (the new message) and I dont know how to fix it... chatview

I tried all in web tutorials and replicate it to, nothing works for me.

2
  • 1
    Depending on how you have your component setup, You can re-render the component using $this->render() in your save() method. Can you post the component code so someone can better assist you? Commented Nov 7, 2022 at 21:31
  • Welcome to SO ! Please avoid to share your code as image. Commented Nov 8, 2022 at 9:40

1 Answer 1

2

You can instruct Livewire to run a certain function that the polling will call. Make sure that in that function your do a ->fresh() on the data you want to refresh.

Example:

<div wire:poll="updateMessages">
    @foreach($userMessages as $userMessage)
      ...loop here...
    @endforeach
</div>
public Collection $messages;

function updateMessages()
{
    $this->messages->fresh();
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.