mysterious-toddler-20573
04/07/2022, 3:49 PMmysterious-toddler-20573
04/07/2022, 3:49 PMcareful-potato-89071
04/07/2022, 3:49 PMmysterious-toddler-20573
04/07/2022, 3:52 PMmysterious-toddler-20573
04/07/2022, 7:20 PMpowerful-eye-47205
04/07/2022, 7:25 PMhx-get with hx-push-url to open a modal window and update the location bar (brilliant!). But now I'm struggling with how the "cancel" link should dismiss the window and re-update the location bar. Is this within the scope of HTMX or do I need to kick out to some regular old JS for this?mysterious-toddler-20573
04/07/2022, 7:25 PMpowerful-eye-47205
04/07/2022, 7:40 PMlate-king-98305
04/07/2022, 8:01 PMHX-Push response header to update the URL.) These were Bootstrap modals; I described how I did it at https://blog.bitbadger.solutions/2021/a-tour-of-myprayerjournal-v3/bootstrap-integration.html#Modal-Dialogs .hundreds-camera-24900
04/07/2022, 8:19 PMhundreds-camera-24900
04/07/2022, 8:20 PMhundreds-camera-24900
04/07/2022, 8:20 PMhundreds-camera-24900
04/07/2022, 8:21 PMpowerful-eye-47205
04/07/2022, 8:29 PMpowerful-eye-47205
04/07/2022, 8:31 PMhx-remove to simply remove a DOM element with the hx-trigger event.mysterious-toddler-20573
04/07/2022, 8:32 PMmysterious-toddler-20573
04/07/2022, 8:32 PMmysterious-toddler-20573
04/07/2022, 8:33 PMhundreds-camera-24900
04/07/2022, 8:37 PMcareful-waiter-81326
04/07/2022, 8:41 PM<button hx-get="{{ url_for('substract_qtyx') }}"
hx-target="#newqt-{{part.invid.data}}"
hx-vals='{ "inv_id": "{{part.invid.data}}","removeqty": "{{part.qty.data}}" }'>
Remove {{part.qty.data}} parts
</button>
as you see it is going to update the #newqt-XXXX with a value, but while it is doing it, is there a way to make the button itself dissapear ?
of course if I do this:
<button hx-get="{{ url_for('substract_qtyx') }}"
hx-swap="delete"
hx-vals='{ "inv_id": "{{part.invid.data}}","removeqty": "{{part.qty.data}}" }'>
Remove {{part.qty.data}} parts
</button>
The button will go away, but the hx-target="#newqt-{{part.invid.data}}" will not be replaced.
There is a way to do both at once ?mysterious-toddler-20573
04/07/2022, 8:47 PMcareful-waiter-81326
04/07/2022, 8:49 PM<button hx-get="{{ url_for('substract_qtyx') }}"
hx-swap="outerHTML"
hx-target="#newqt-{{part.invid.data}}"
hx-swap-oob="true"
hx-vals='{ "inv_id": "{{part.invid.data}}","removeqty": "{{part.qty.data}}" }'>
Remove {{part.qty.data}} parts
</button>mysterious-toddler-20573
04/07/2022, 8:49 PMmysterious-toddler-20573
04/07/2022, 8:49 PMcareful-waiter-81326
04/07/2022, 8:51 PM@app.route('/substract_qtyx', methods=['GET', 'POST'])
@login_required
def substract_qtyx():
inv_id = request.args.get("inv_id")
removeqty = request.args.get("removeqty")
print(f"{removeqty}")
return 'hx-swap-oob="true"'
and of course when I do this the content on the hx-target="#newqt-{{part.invid.data}}" is replaced with this exact text !careful-waiter-81326
04/07/2022, 8:58 PMcareful-waiter-81326
04/07/2022, 11:14 PMcareful-waiter-81326
04/07/2022, 11:15 PMcareful-waiter-81326
04/07/2022, 11:20 PM<td style="text-align:center;"> 9
<span id="newqt-2125">XXX</span>
</td>
<td style="text-align:center;">
<button id="btn-2125" hx-get="/substract_qtyx"
hx-swap="outerHTML"
hx-swap-oob="true"
hx-target="#btn-2125" <---------------------------- HERE I TARGET the #btn-2125 or the #newqt-2125
hx-vals='{ "inv_id": "2125","removeqty": "1" }'>
Remove 1 parts
</button>
</td>
and my python
@app.route('/substract_qtyx', methods=['GET', 'POST'])
@login_required
def substract_qtyx():
inv_id = request.args.get("inv_id")
removeqty = request.args.get("removeqty")
print(inv_id)
print(inv_id)
return '<span></span>'