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-on::after-request does not fire after hx-delete #3177

Open
hassanad94 opened this issue Feb 8, 2025 · 2 comments
Open

hx-on::after-request does not fire after hx-delete #3177

hassanad94 opened this issue Feb 8, 2025 · 2 comments

Comments

@hassanad94
Copy link

hassanad94 commented Feb 8, 2025

<button hx-delete="/api/admin/remove-image" hx-swap="outerHTML" hx-target="closest .swiper-slide"
						hx-on::before-request="alert('Making a request!')"
						hx-on::after-request="alert('Done making a request!')" hx-vals={ `js:{imageID: "` + src + `" ,
						id: getPropertyID() }` } class="delete-image pointer-events-auto focus:outline-none hover:bg-gray-300 p-1 rounded-md
						bg-white">
						<svg class="fill-current w-4 h-4" xmlns="http://www.w3.org/2000/svg" width="24" height="24"
							viewBox="0 0 24 24">
							<path class="pointer-events-none"
								d="M3 6l3 18h12l3-18h-18zm19-4v2h-20v-2h5.711c.9 0 1.631-1.099 1.631-2h5.316c0 .901.73 2 1.631 2h5.711z" />
						</svg>
					</button>

With hx-post everthing works just fine, but if i use it with hx-delete, hx-on::after-request would not fire.

@Telroshan
Copy link
Collaborator

Hey, that's weird, do you get any errors in the console?
Also, could you share screenshots of the responses of both requests (POST and DELETE) to see if anything differs between those two? The response headers, as well as its content

@ilianbronchart
Copy link

Hi, the same thing is happening for me. When I remove the hx-target line, it works. Also, if I change hx-delete to hx-post it also works.

<button class="btn btn-sm btn-danger"
      hx-delete="/simrooms/{{ sim_room.id }}/classes/{{ class.id }}"
      hx-target="#class-list"
      hx-on::after-request="alert('TEST')">
</button>

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

No branches or pull requests

3 participants