hundreds-cartoon-20446
12/29/2022, 3:38 PMhundreds-cartoon-20446
12/29/2022, 3:43 PMhundreds-cartoon-20446
12/29/2022, 3:44 PMhundreds-cartoon-20446
12/29/2022, 3:47 PMhx-history=“false”
feature will prevent a page cache being saved to localStorage, but history state changes will still work as expected. It’s most useful for security reasons (preventing sensitive data being saved to the client which may be a public / shared machine).limited-potato-46306
12/29/2022, 3:55 PMhundreds-cartoon-20446
12/29/2022, 3:56 PMhundreds-cartoon-20446
12/29/2022, 3:59 PM<div
hx-history-preserve
hx-get="/somedata"
hx-trigger="load">
</div>
limited-potato-46306
12/29/2022, 4:05 PMhundreds-cartoon-20446
12/29/2022, 4:10 PM"Cache-Control: no-cache, max-age=0, must-revalidate, no-store"
limited-potato-46306
12/29/2022, 4:28 PMhundreds-cartoon-20446
12/29/2022, 4:39 PMhundreds-cartoon-20446
12/29/2022, 4:39 PMhundreds-cartoon-20446
12/29/2022, 4:41 PMlimited-potato-46306
12/29/2022, 4:54 PMwhite-motorcycle-95262
12/29/2022, 7:26 PMhx-params
(and maybe hyperscript) to only submit form fields that have values in an hx-get
situation? Since I'm using hx-push-url="true"
, I'm getting empty URL params in the address bar that I'd like to remove if possible. The actual form is being submitted by hyperscript using requestSubmit() the #form-id
mysterious-toddler-20573
12/29/2022, 7:28 PMhtmx:configRequest
event and remove the empty values from the detail.parameters
object: https://htmx.org/events/#htmx:configRequestwhite-motorcycle-95262
12/29/2022, 7:28 PMbroad-pencil-64390
12/30/2022, 5:24 PMa
b
c
inputs.
html
<form hx-get="some/url">
<label><input name="a" type="checkbox"> A</label>
<label><input name="b" type="checkbox"> B</label>
<label><input name="c" type="checkbox"> C</label>
</form>
is there a better way than do something like adding: hx-get="some/url"
and hx-include="input"
on all the inputs?broad-pencil-64390
12/30/2022, 5:38 PMhundreds-camera-24900
12/30/2022, 6:35 PMsome-solstice-89459
12/30/2022, 8:13 PMlimited-potato-46306
12/30/2022, 8:56 PMif (name === "htmx:beforeSwap") {
// Take a snapshot of the initial dom state of a page before it is rendered.
// This is called *before* htmx:beforeHistorySave, so we need to save the
// snapshot for the *next* history save
var incomingDOM = new DOMParser().parseFromString(event.detail.xhr.response, "text/html");
var historyElt = incomingDOM.querySelector(historyEltSelector);
console.log(historyElt)
if (historyElt) {
historySnapshotNext = historyElt.innerHTML;
}
}
clever-activity-24633
12/30/2022, 10:58 PMlimited-potato-46306
12/31/2022, 12:32 AMif (name === "htmx:beforeSwap") {
// Take a snapshot of the initial dom state of a page before it is rendered.
// This is called *before* htmx:beforeHistorySave, so we need to save the
// snapshot for the *next* history save
var incomingDOM = new DOMParser().parseFromString(event.detail.xhr.response, "text/html");
var historyElt = incomingDOM.querySelector(historyEltSelector);
if (historyElt) {
historySnapshotNext = historyElt.innerHTML;
}
}
In the beforeSwap event, it appears that the incoming DOM is ignored if there is no element with hx-history-elt. If each of my "pages" in a SPA (boosted links), have the hx-history-elt element, then everything works with hx-history-preserve. If a page does not have the hx-history-elt element, then hx-history-preserve doesn't work. Previously, I had always had boosted links replace the inner html a top level div that had hx-history-elt defined. I had never used multiple hx-history-elt directives, so I want to make sure I am not somehow using the extension in a way you hadn't intended.rich-answer-94291
12/31/2022, 1:13 AM<td><div class="actions" style="margin: auto">
<span class="material-icons">print</span>
<span hx-get="/" hx-trigger="click" class="material-icons">create</span>
</div>
</td>
limited-potato-46306
12/31/2022, 1:43 AMrich-answer-94291
12/31/2022, 1:50 AMadventurous-ocean-93733
12/31/2022, 2:28 AMrich-answer-94291
12/31/2022, 2:30 AMadventurous-ocean-93733
12/31/2022, 2:39 AM