Skip to content

Add hx-swap support to hx-ext="sse" #844

@rajasimon

Description

@rajasimon

Hi there, I've testing sse extension in my project and it's working as expected for swapping the content. However, I want to add new message below like chat message. And when I tried hx-swap with hx-target but that also seems to update the target instead of appending it.

<div hx-ext="sse" sse-connect="/search/{{ query.id }}/" sse-swap="message" hx-target="#result" hx-swap="beforeEnd">
  Hang tight we are fetching your results.
  <div id="result"></div>
</div>

Screenshot 2022-02-26 at 1 04 16 PM

I need the end result should be like append into each box.

<div hx-ext="sse" sse-connect="/search/{{ query.id }}/" sse-swap="message" hx-target="#result" hx-swap="beforeEnd">
  Hang tight we are fetching your results.
  <div id="result">
    <div class="box></div>
    <div class="box></div>
    <div class="box></div>
    <!--  As soon as new message arrives this result get appended.-->
  </div>
</div>

Let me know if this possible with sse or any alternatives thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions