hundreds-camera-24900
01/02/2023, 11:22 PMhundreds-camera-24900
01/02/2023, 11:23 PMhtml
selectionInfo.elt
<input placeholder="Email" autocomplete="email" required id="id_email" type="text" name="email" value="test@test.com">
hundreds-camera-24900
01/02/2023, 11:24 PMhundreds-camera-24900
01/02/2023, 11:56 PMhundreds-camera-24900
01/03/2023, 12:02 AMhundreds-camera-24900
01/03/2023, 12:02 AMhundreds-camera-24900
01/03/2023, 12:03 AMmysterious-toddler-20573
01/03/2023, 12:09 AMmysterious-toddler-20573
01/03/2023, 12:09 AMhundreds-camera-24900
01/03/2023, 12:10 AMhundreds-camera-24900
01/03/2023, 12:10 AMhundreds-camera-24900
01/03/2023, 12:11 AMhundreds-camera-24900
01/03/2023, 12:12 AMhundreds-camera-24900
01/03/2023, 1:00 AMjs
it("can trigger swaps from fields that don't support setSelectionRange", function(){
const template = '<form hx-get="/test">\n' +
'<input value="test@test.com" type="email" id="id_email" />\n' +
'<input type="submit" id="id_button" />\n' +
'</form>';
const response = '<form hx-get="/test">\n' +
'<input value="supertest@test.com" type="email" id="id_email" />\n' +
'<input type="submit" id="id_button" />\n' +
'</form>';
this.server.respondWith("GET", "/test", response);
make(template);
var input = byId("id_email");
input.dispatchEvent(new KeyboardEvent('keypress', {"key": "Enter"}));
this.server.respond();
input.value.should.equal("supertest@test.com");
})
hundreds-camera-24900
01/03/2023, 1:06 AMmysterious-toddler-20573
01/03/2023, 3:27 PMlate-king-98305
01/03/2023, 10:03 PMlate-king-98305
01/03/2023, 10:13 PMjolly-waitress-42858
01/04/2023, 1:38 AMmodern-continent-13743
01/04/2023, 3:44 AMfew-fish-46602
01/04/2023, 2:02 PMrich-television-50179
01/04/2023, 2:12 PM<button id="delete-button" hx-post="/delete" hx-confirm="Are you sure you want to delete?">Delete Me!</button>
When I load the web app and check console, it shows that htmx.min.js
was loaded successfully but for some reason when I click the button nothing happens. No browser confirm alert or post request. I use Firefox Developer Edition for my preferred browser.late-king-98305
01/04/2023, 2:12 PM<select>
that does a GET based on what the user selects, you can use hx-get
and hx-target
to put that content somewhere else. It's a different way of thinking about API endpoints.
Conversely, when JavaScript adds elements to a page, htmx doesn't know anything about those elements. This is probably the biggest "gotcha" - htmx can't act on elements it doesn't know about. However, running htmx.process()
on those elements make it aware of them https://htmx.org/api/#process .
Anyway, hope that helps. Deciding how to break up the requests and the HTML partials is probably the biggest decision point, and sometimes the whole "make it as narrow and targeted as possible" mindset that works well in some architectures could very well add complexity you don't need.
p.s. I've looked into both _hyperscript and Alpine.js, but in my use cases, I've been fine with plain ol' JS, but other folks may be better advocates for them. 🙂jolly-waitress-42858
01/04/2023, 2:17 PMmysterious-toddler-20573
01/04/2023, 2:18 PMmysterious-toddler-20573
01/04/2023, 2:18 PMmysterious-toddler-20573
01/04/2023, 2:19 PMrich-television-50179
01/04/2023, 2:19 PMrich-television-50179
01/04/2023, 2:20 PMfew-fish-46602
01/04/2023, 2:22 PM