gentle-notebook-11755
04/03/2022, 4:26 PMbrainy-ice-92385
04/03/2022, 5:11 PMhundreds-camera-24900
04/03/2022, 5:34 PMbrainy-ice-92385
04/03/2022, 5:51 PMmysterious-toddler-20573
04/03/2022, 8:35 PMpowerful-eye-47205
04/03/2022, 9:47 PMgentle-notebook-11755
04/03/2022, 9:55 PMhundreds-camera-24900
04/04/2022, 12:37 AMgentle-notebook-11755
04/04/2022, 1:06 AMhtml
<sl-icon-button
class = "htmx_trigger not_ready"
library = "ma_icons"
name = "ma_search"
hx-trigger="click"
hx-get= "/search"
href = "/search"
label = "search"></sl-icon-button>
2. Remove the component's default behavior, and whenever a new page loads (via htmx) call the same function again so that any component embedded in the loeaded html, is prevented from doing its default behavior either.
js
// Removes default behavior
htmx_aware = () => {
const sl_elements = document.querySelectorAll('.htmx_trigger.not_ready');
for (let i = 0; i < sl_elements.length; i++) {
sl_elements[i].addEventListener('click', e => {
e.preventDefault();
e.target.classList.remove('not_ready');
})
}
}
// called once, when very first page loads
htmx_aware();
// called whenever a new page loads via htmx
body.addEventListener("htmx:load", function (evt) {
htmx_aware();
});faint-egg-43233
04/04/2022, 11:36 AMlate-king-98305
04/04/2022, 12:11 PM} character at the end of the button declaration is throwing anything off; it was in both of your examples. You might also want to see if the preventDefault type of thing that was discussed yesterday (surrounding buttons and behaviors like this) may also be causing the problem you're seeing.sparse-cat-39392
04/04/2022, 12:17 PMmysterious-toddler-20573
04/04/2022, 1:25 PMmysterious-toddler-20573
04/04/2022, 1:26 PMgreen-flower-49070
04/04/2022, 3:53 PMgreen-flower-49070
04/04/2022, 3:54 PMhundreds-camera-24900
04/04/2022, 3:59 PMgreen-flower-49070
04/04/2022, 4:03 PMhundreds-camera-24900
04/04/2022, 4:25 PMfew-vegetable-15970
04/04/2022, 4:50 PMhx-select attribute needs more visibility to encourage the gradual adoption of htmx since, using it, you can improve your front UX without touching a single line of the backend source code. You can just add an ID at the good place and set it in both hx-target and hx-select.
I'm actually working on a dummy django example project to show the concept. When I finish it, I will post a link here to see your opinions guys.
Maybe it was done by someone else before, but I didn't find anything on this.green-flower-49070
04/04/2022, 4:59 PMhundreds-camera-24900
04/04/2022, 4:59 PMsparse-cat-39392
04/04/2022, 5:05 PMmysterious-toddler-20573
04/04/2022, 5:06 PMmysterious-toddler-20573
04/04/2022, 5:08 PMhtml
<div hx-post="/car_options" hx-trigger="change">
<select name="make">
<option>Option 1<option>
...
<select>
<select name="model">
<option>Option 1<option>
...
<select>
<select name="engine">
<option>Option 1<option>
...
<select>
...
</div>mysterious-toddler-20573
04/04/2022, 5:08 PMsparse-cat-39392
04/04/2022, 5:27 PMmysterious-toddler-20573
04/04/2022, 5:41 PMsparse-cat-39392
04/04/2022, 7:22 PMmysterious-toddler-20573
04/04/2022, 7:25 PMhx-post onto the parent div, set the URL to a full path, and add a hx-trigger='change' I would also put the div inside the form, so all the selects are included in the request. Finally, I don't think you need hx-params as that's mainly for filtering. Here you want everything inside the form.