powerful-train-54786
07/07/2022, 2:32 PMpowerful-train-54786
07/07/2022, 2:36 PMpowerful-train-54786
07/07/2022, 2:37 PMmysterious-toddler-20573
07/07/2022, 2:37 PMmysterious-toddler-20573
07/07/2022, 2:38 PM204 - No Content
response code: https://htmx.org/docs/#requestspowerful-train-54786
07/07/2022, 2:41 PMblue-ghost-19146
07/07/2022, 5:11 PMHX-Trigger: openCreateModal
from my server, and listening to it on a button like:
<button id="open-modal-btn" hx-trigger="click, openCreateModal from:body“ hx-get="{% url 'open-modal' %}" hx-etc…>
Create Project
</button>
On click, this calls the open-modal
endpoint and swaps the modal content into the page, but the openCreateModal
event doesn’t seem to trigger. This is for first page load, so users can copy and paste a URL with a payload like ?modal=createProject
into their browser and it would automatically open the modal. As this is on page load, I can’t seem to inspect the events being fired in the browser console. Any ideas why this isn’t working?blue-ghost-19146
07/07/2022, 7:01 PMripe-action-67367
07/07/2022, 7:24 PMload
or revealed
event for similar effect https://htmx.org/attributes/hx-trigger/blue-ghost-19146
07/07/2022, 7:42 PMdelightful-midnight-18834
07/07/2022, 11:51 PMdelightful-midnight-18834
07/08/2022, 12:08 AMhx-select="tbody > tr"
just use a normal css selector to get all tr childs from tbodywooden-tailor-56752
07/08/2022, 8:31 AMblue-ghost-19146
07/08/2022, 9:06 AMhx-include
sounds like the correct approach if the textarea
is not inside the post
-ing element (often a form). There is also `htmx:configRequest`: https://htmx.org/events/#htmx:configRequest and `hx-vals`: https://htmx.org/attributes/hx-vals/blue-ghost-19146
07/08/2022, 9:07 AMhx-include
should be in the request payload in its original, non-url-encoded format, even if it also shows in the url params. That's my understanding of it anywayfancy-elephant-10660
07/08/2022, 10:08 AMbest-rose-8837
07/08/2022, 10:25 AMmysterious-toddler-20573
07/08/2022, 1:04 PMfancy-elephant-10660
07/08/2022, 1:05 PMmysterious-toddler-20573
07/08/2022, 1:05 PMhx-include
. There is no hx-body
attribute. You can target other elements with hx-target
or using out of band swaps, if that's what you mean, and if the server is returning JSON you can use the client side templates extension as a base for your own code.late-king-98305
07/08/2022, 4:33 PMform
, then put the link with the ID to be deleted into the URL which is posted via hx-post
. This way, it includes the CSRF tokens, but each item's "Delete" link posts to the correct endpoint for that item. I don't know if you're solving a similar issue, but that pattern should work for any sort of values you want to have "automatically" included in your POST.
This example uses Liquid, but as long as you structure your HTML in a similar way, you should get similar results. https://github.com/bit-badger/myWebLog/blob/main/src/admin-theme/category-list-body.liquidsteep-lamp-42308
07/08/2022, 4:47 PMhx-post
inside a form will submit all the form elements.late-king-98305
07/08/2022, 5:19 PMwooden-tailor-56752
07/08/2022, 8:12 PMmysterious-toddler-20573
07/08/2022, 8:27 PMmysterious-toddler-20573
07/08/2022, 8:27 PMmysterious-toddler-20573
07/08/2022, 8:27 PMmysterious-toddler-20573
07/08/2022, 8:27 PMmysterious-toddler-20573
07/08/2022, 8:27 PMbest-rose-8837
07/08/2022, 9:26 PM