htmx
htmx copied to clipboard
target input type text should set the value attribute
It was this old issue, i believe it didn't change ? Should we use outerHTML only or is there a way to swap to value ?
https://github.com/bigskysoftware/intercooler-js/issues/229
I'm guessing that outerHTML works for you and you are looking for a HTMX to always treat hx-swap="innerHTML" on inputelements asouterHTML`?
outerHTML works, but it could be fine that innerHTML on an input box change the value of the input.
I think this would be best as it follows the principle of least surprise.
As a work-around:
document.addEventListener("htmx:beforeSwap", e => {
if (e.detail.target.tagName === 'INPUT') {
e.preventDefault();
e.detail.target.value = e.detail.serverResponse;
}
});