broad-pencil-64390
11/21/2022, 6:06 PMFailed to execute 'querySelector' on 'Element': '#.field-status' is not a valid selector.
Can hx-select-oob
only be used to select ids? I got the above error when having hx-select-oob=".field-status"
broad-pencil-64390
11/21/2022, 6:12 PM.field-status
is a child of the hx-target
🤔
..even though hx-swap is using afterbegin
thankful-cat-54263
11/21/2022, 7:20 PMquick-crayon-19412
11/21/2022, 9:41 PMhtml
<form sprig s-action="entries/save-entry" s-method="post" hx-ext="bs-validation" class="needs-validation" novalidation>
...
<input id="customField" name="fields[customField]" type="text" required />
</form>
js
htmx.defineExtension('bs-validation', {
onEvent: function (name, evt, data) {
if (name !== "htmx:afterProcessNode") {
return;
}
let form = evt.detail.elt;
// check if trigger attribute and submit event exists
// for the form
if(!form.hasAttribute('hx-trigger')){
// set trigger for custom event bs-send
form.setAttribute('hx-trigger','bs-send');
// and attach the event only once
form.addEventListener('submit', function (event) {
if (form.checkValidity()) {
// trigger custom event hx-trigger="bs-send"
htmx.trigger(form, "bsSend");
}
// focus the first invalide field
let invalidField = form.querySelector(':invalid');
if(invalidField) {
invalidField.focus();
}
event.preventDefault()
event.stopPropagation()
form.classList.add('was-validated')
}, false)
}
}
});
busy-tomato-43957
11/21/2022, 10:52 PMbusy-tomato-43957
11/21/2022, 10:59 PMbrainy-ice-92385
11/22/2022, 12:51 AMbusy-tomato-43957
11/22/2022, 12:56 AMbrainy-ice-92385
11/22/2022, 12:57 AMbusy-tomato-43957
11/22/2022, 12:58 AMboundless-leather-51644
11/22/2022, 10:21 AMboundless-leather-51644
11/22/2022, 10:22 AMhtmx:responseError
?boundless-vase-80440
11/22/2022, 12:22 PMboundless-vase-80440
11/22/2022, 12:22 PMsalmon-oil-67352
11/22/2022, 8:42 PM<form
hx-encoding='multipart/form-data'
hx-post="{% url 'invoices_to_be_processed_upload' %}"
hx-target="#invoice_to_be_processed_table"
>
<input type='file' name='invoice_file' multiple>
<button type="submit">
{% trans "Upload" %}
</button>
</form>
Is this normal?mysterious-toddler-20573
11/22/2022, 9:07 PMmysterious-toddler-20573
11/22/2022, 9:08 PMmysterious-toddler-20573
11/22/2022, 9:08 PMmysterious-toddler-20573
11/22/2022, 9:09 PMsalmon-oil-67352
11/22/2022, 9:16 PMsalmon-oil-67352
11/22/2022, 9:17 PMsalmon-oil-67352
11/22/2022, 9:17 PMreturn render(
request,
"partials/invoice_to_be_processed_table.html",
context={
"invoices": invoices,
},
)
salmon-oil-67352
11/22/2022, 9:18 PMsalmon-oil-67352
11/22/2022, 9:24 PMmysterious-toddler-20573
11/22/2022, 9:31 PMsalmon-oil-67352
11/22/2022, 9:38 PMmysterious-toddler-20573
11/22/2022, 9:39 PMbrash-house-85887
11/22/2022, 11:16 PM<script language="javascript">
with a htmx.on('htmx:afterSettled'..)
works as expected. But if I do include an hx-swap-oob div (in addition to the normal, non-swap-oob div) then it never gets called regardless of where I put it in the response. Is there something I'm missing?mysterious-toddler-20573
11/22/2022, 11:19 PMmysterious-toddler-20573
11/22/2022, 11:20 PM