Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hx-ext="sse" elements should include hx-vals attributes as query params #34

Open
bradleyjkemp opened this issue Jun 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@bradleyjkemp
Copy link

I want to be able send some dynamic query params as part of an sse request like so:

<div hx-ext="sse" sse-connect="/events" hx-vals="js:{dynamicValue: foo()}>

But the hx-vals are not included in the eventsource connect:

// handle extension source creation attribute
if (api.getAttributeValue(elt, 'sse-connect')) {
var sseURL = api.getAttributeValue(elt, 'sse-connect')
if (sseURL == null) {
return
}
ensureEventSource(elt, sseURL, retryCount)

function ensureEventSource(elt, url, retryCount) {
var source = htmx.createEventSource(url)

Only the value of sse-connect is used

@Telroshan Telroshan added the enhancement New feature or request label Jul 10, 2024
@ErikEngerd
Copy link

The same issue also applies to the ws extension.

@fastpok
Copy link

fastpok commented Oct 14, 2024

I had a similar problem with WebSockets extension. Try changing single quotes to double quotes.

This did not work for me:
hx-vals="{'a': 'b'}"

But this one worked:
hx-vals="{"a": "b"}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants