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-vals does not work together with delay #1189

Open
sigsegvat opened this issue Jan 3, 2023 · 3 comments · May be fixed by #3196
Open

hx-vals does not work together with delay #1189

sigsegvat opened this issue Jan 3, 2023 · 3 comments · May be fixed by #3196
Labels
bug Something isn't working

Comments

@sigsegvat
Copy link

It seems that the event object is not passed to the jx-vals expression when using a delay modifier in hx-trigger (see code below).

<div contenteditable="true" hx-post="/test" contenteditable="true" hx-trigger="input delay:1s" 
     hx-vals="js:{text: convertEvent(event)}"
     >doesn't work</div>

<div contenteditable="true" hx-post="/test" contenteditable="true" hx-trigger="input" 
     hx-vals="js:{text: convertEvent(event)}"
     >works</div>
     
 window.convertEvent= function(event) {
  console.log(event)
  return event.target.innerHTML
}    
@GlennWSo
Copy link

I have also noticed this problem

@ahmed-com
Copy link

any update on this issue ? any work around ?

@Telroshan Telroshan added the bug Something isn't working label Dec 16, 2024
@scrhartley
Copy link
Contributor

scrhartley commented Feb 19, 2025

Workaround:

<div contenteditable="true" hx-post="/test" contenteditable="true" hx-trigger="myinput" 
     hx-vals="js:{text: convertEvent(event)}"
     oninput="setTimeout(evt => htmx.trigger(evt.target, 'myinput', {cause: evt}), 1000, event)"
     ></div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants