lively-beach-14291
10/12/2020, 2:09 PMlively-beach-14291
10/12/2020, 2:10 PMlively-beach-14291
10/12/2020, 3:14 PMmost-jelly-15242
10/12/2020, 3:18 PMhx-get="increment"
that triggers a request to /yoyo?index.php?component=counter/increment
. Then on the server side I use the component
parameter to figure out which component needs to be re-rendered.most-jelly-15242
10/12/2020, 3:19 PM/yoyo
route is just for updating individual components.most-jelly-15242
10/12/2020, 3:21 PMcounter
from the HTML markup yoyo:name="counter"
so it can include it in the request URL.crooked-angle-63874
10/12/2020, 4:13 PMmysterious-toddler-20573
10/12/2020, 4:21 PMcrooked-angle-63874
10/12/2020, 4:28 PMuser
10/12/2020, 7:14 PM<button hx-get="#template">Click me</button>
where template is <template id="template"><div>hello world</div></template>
?user
10/12/2020, 7:15 PM<button hx-select="#template">Click me</button>
user
10/12/2020, 7:16 PMmysterious-toddler-20573
10/12/2020, 8:03 PMjavascript:
mysterious-toddler-20573
10/12/2020, 8:05 PMmysterious-toddler-20573
10/12/2020, 8:05 PMjs
// don't process 'No Content'
if (this.status !== 204) {
user
10/12/2020, 8:16 PMuser
10/12/2020, 8:16 PMcrooked-angle-63874
10/12/2020, 9:16 PMcrooked-angle-63874
10/12/2020, 9:17 PMcrooked-angle-63874
10/12/2020, 9:17 PMmost-jelly-15242
10/16/2020, 8:24 PMbeforeend
swap only append when the ID isn't already there? If it's there then it swaps the existing element? A use-case for this would be for modals where you have a list of items with edit buttons. You click one button, it appends the modal HTML to the body using htmx. Then you close the modal, click another button and instead of appending a new modal, it re-uses the existing one based on the existing ID attribute. Or maybe there's a more practical way to do this? The reason why I want to append the modal to begin with, instead of just having a div there on page load, is because I may not have control over the entire page.mysterious-toddler-20573
10/16/2020, 8:29 PMmost-jelly-15242
10/16/2020, 8:34 PMmost-jelly-15242
10/16/2020, 8:35 PMmost-jelly-15242
10/16/2020, 8:42 PMmost-jelly-15242
10/16/2020, 10:34 PMhtmx:processedNode
event. Read hx-target
value there. If it's an ID (e.g. #some-id
), then find the element and create if it's not already there.mysterious-toddler-20573
10/16/2020, 11:13 PMmost-jelly-15242
10/16/2020, 11:24 PMmysterious-toddler-20573
10/16/2020, 11:35 PMmysterious-toddler-20573
10/17/2020, 7:32 PM