careful-waiter-81326
04/07/2022, 11:28 PM<td style="text-align:center;"> 9
<span id="newqt-2125">XXX</span>
</td>
<td style="text-align:center;">
</td>
<td style="text-align:center; font-weight: bold;">A-M-12</td>
<td style="text-align:center;">
<!-- <a href="/substract_qty/2125/1/8960-1"> <input type="button" value="Remove 1 parts"></a> -->
<button id="btn-2125" hx-get="/substract_qtyx"
hx-swap="None" <------------------------------------- I WANT TO THIS ON THE BUTTON
hx-swap-oob="outerHTML#newqt-2125" <--------------------------------- AND WANT TO DO THIS TOO
hx-target="#btn-2125"
hx-vals='{ "inv_id": "2125","removeqty": "1" }'>
Remove 1 parts
</button>
</td>careful-waiter-81326
04/07/2022, 11:57 PM<span id="newqtX">XXX</span>
.........................
.... Lot of html code ...
.........................
<button id="btnX" hx-get="/substract_qtyx"> Remove the button after click and update XXX to GGG </button>
I believe I'm missing the correct answer. (FYI in reality, there is a lot of data between the and the hundreds-camera-24900
04/08/2022, 12:25 AMhundreds-camera-24900
04/08/2022, 12:26 AMhundreds-camera-24900
04/08/2022, 12:27 AMcareful-waiter-81326
04/08/2022, 12:45 AMcareful-waiter-81326
04/08/2022, 1:17 AM<td style="text-align:center;"> {{ part.oriqty.data }}<br>
<span id="newqt-{{part.invid.data}}"></span>
</td>
<button id="btn-{{part.invid.data}}" hx-get="{{ url_for('substract_qtyx') }}"
hx-swap="delete"
hx-vals='{ "inv_id": "{{part.invid.data}}","oriqty": "{{part.oriqty.data}}","removeqty": "{{part.qty.data}}" }'>
Remove {{part.qty.data}} parts
</button>
and my return is:
@app.route('/substract_qtyx', methods=['GET', 'POST'])
@login_required
def substract_qtyx():
return "<span style='color:red;' hx-swap-oob='outerHTML:#newqt-2125'>8</span>"careful-room-54859
04/08/2022, 7:25 PMhx-get path. Is this possible? This is to allow for me to have a dynamic cascading select.careful-room-54859
04/08/2022, 7:28 PMhx-get='/select-options/entity/{"entity_name": "customer"}'careful-room-54859
04/08/2022, 7:28 PMcustomer be the value of the SELECT from which the change event triggers the hx-get?eager-tiger-27508
04/08/2022, 7:29 PMhx-get basically? @Usereager-tiger-27508
04/08/2022, 7:30 PMcareful-room-54859
04/08/2022, 7:30 PMhx-get so that it contains whatever value from the select....eager-tiger-27508
04/08/2022, 7:31 PMeager-tiger-27508
04/08/2022, 7:32 PMhtmx attributes can't be dynamic.careful-room-54859
04/08/2022, 7:33 PM<select id="entity"
hx-trigger="change"
hx-get='/select-options/model_field/{"model_name": "me.value"}'
hx-target="entity-list"
...></select>
...
<select id="entity-list"
<option ..>COMES FROM THE CHANGE EVENT ABOVE</option>
</select>careful-room-54859
04/08/2022, 7:33 PMhx-geteager-tiger-27508
04/08/2022, 7:35 PM/select-options/model_field/{"model_name": "me.value"}. Why is there JSON? Are you trying to attach a request body? Or does your backend accept that format?careful-room-54859
04/08/2022, 7:36 PMeager-tiger-27508
04/08/2022, 7:37 PMeager-tiger-27508
04/08/2022, 7:38 PMeager-tiger-27508
04/08/2022, 7:39 PMcareful-room-54859
04/08/2022, 7:40 PMmost-activity-91725
04/08/2022, 7:48 PMselect element is given a name attribute, htmx will automatically provide the key-val map along with the hx-get request—the URL would just look like this, instead: select-options/entity?entity_name=customermost-activity-91725
04/08/2022, 7:48 PMcareful-room-54859
04/08/2022, 7:57 PMmost-activity-91725
04/08/2022, 7:58 PMmost-activity-91725
04/08/2022, 8:03 PMcareful-room-54859
04/08/2022, 10:01 PMblue-gold-89534
04/08/2022, 11:54 PMhtml
<tr id="editProductRow"
hx-target="#editProductRow"
hx-encoding="multipart/form-data"
hx-swap="outerHTML"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-include="#editProductRow"
hx-trigger="target:#submitbutton">
<many tds with different strings in them and some hidden ones with b64 images>
<!-- post the update -->
<td>
<img id="submitbutton"
type="submit"
hx-post="{% url 'update' object.pk %}?page={{ page }}"
hx-trigger="click[showEditButtons()]"
src="{% static 'save.svg' %}">
</td>
</tr>
everything works in testing, but in deployment I got errors. So I checked the URLs from for example {% url 'update-cancel' object.pk %}?page={{ page }} which I would expect to look something like this:
http://127.0.0.1:8003/productupdatecancel/140?page=1
but I can see under "headers" in the network tab of the webdev console it looks like this:
http://127.0.0.1:8003/productupdatecancel/140?page=1&number=3&name=testproduct&price=4.2&img_hidden=logo.png___data%3Abase64encodedimagestringhere........
I suspect the hx-include makes my attributes end up in the header instead of the request body. How can I fix this?