jolly-kite-167
03/31/2022, 6:56 PMlate-king-98305
03/31/2022, 8:57 PMmysterious-toddler-20573
03/31/2022, 10:20 PMmysterious-toddler-20573
03/31/2022, 10:21 PMbrash-spoon-98243
04/01/2022, 7:32 AMbland-coat-6833
04/01/2022, 5:33 PMbland-coat-6833
04/01/2022, 5:35 PMbland-coat-6833
04/01/2022, 5:36 PMjolly-kite-167
04/01/2022, 5:36 PMabundant-planet-84751
04/01/2022, 8:16 PMmysterious-toddler-20573
04/01/2022, 8:41 PMmysterious-toddler-20573
04/01/2022, 8:41 PMrhythmic-dream-52762
04/01/2022, 8:58 PMgentle-notebook-11755
04/02/2022, 3:44 PMmammoth-family-48524
04/02/2022, 10:24 PMgentle-notebook-11755
04/02/2022, 11:55 PM<sl-icon-button
id = "search_btn"
library = "ma_icons"
name = "ma_search"
href = "/search"
label = "search">
</sl-icon-button>
Normal links work as expected with HTMX. But this icon button, for instance, is ignored. And just in case, these are the attributes on the body (very standard htmx, nothing fancy):
<body
hx-boost="true"
hx-push-url = "true"
hx-select = ".site-main"
hx-target = ".site-main"
hx-swap = "outerHTML swap:250ms settle:100ms show:unset"
hx-indicator ="#loader"
....
>careful-waiter-81326
04/03/2022, 12:31 AM<button name="bt1" hx-trigger="click" hx-post="/clicked" hx-swap="none" value="TESTVALUE"}>
Click Me
</button>
Python code:
@app.route("/clicked", methods=["GET","POST"])
def clicked():
print(f"{request.method=}")
print(f"{request.args=}")
print(f"{request.args.get('bt1')=}")
print(f"I WAS CLICKED")
return ''
The bt1 value is always None instead of TESTVALUEcareful-waiter-81326
04/03/2022, 12:31 AMhundreds-camera-24900
04/03/2022, 12:52 AMcareful-waiter-81326
04/03/2022, 1:07 AMcareful-waiter-81326
04/03/2022, 1:12 AMcareful-waiter-81326
04/03/2022, 1:12 AMcareful-waiter-81326
04/03/2022, 1:24 AM<form method="POST">
<input type="hidden" name="setid" value="{{ setinfo['ITEMID'] }}">
<button hx-trigger="click" hx-post="/clicked" hx-swap="none"}>
Add in my Inventory
</button>
</form>
and for the Python side:
@app.route("/clicked", methods=["GET","POST"])
def clicked():
setid = request.form.get('setid')
print(f"{request.form.get('setid')=}")brainy-ice-92385
04/03/2022, 5:47 AMnpm run test take for people? It seems to be hanging indefinitely on my machinemost-jelly-15242
04/03/2022, 12:01 PMhtmx.process() in the browser dev console after the page loads to see if that allows the button to work. It's possible htmx is processing the nodes before shoelace so it doesn't see the attributes. If this fixes it, then you should find out if shoelace triggers an event after processing all elements on the page so you can run the htmx process command after.gentle-notebook-11755
04/03/2022, 12:43 PM.htmx_trigger to the shoelace component and tried these different options:
htmx.process('.htmx_trigger')
htmx.process(document.querySelector('.htmx_trigger'))
In both cases, the return was undefined and the behavior did not change. Just in case, document.querySelector('.htmx_trigger') does return the shoelace component.
In the meantime, I'm going to ask the folks at shoelace to see what insights they have.full-lawyer-54322
04/03/2022, 2:03 PMmysterious-toddler-20573
04/03/2022, 2:19 PMgentle-notebook-11755
04/03/2022, 3:58 PM<sl-icon-button
class = "htmx_trigger"
library = "ma_icons"
name = "ma_search"
hx-trigger="click"
hx-get= "/search"
href = "/search"
label = "search"></sl-icon-button>
<script>
const btns = document.querySelectorAll('.htmx_trigger');
for (let i = 0; i < btns.length; i++) {
btns[i].addEventListener('click', e => {
e.preventDefault();
})
}
</script>
I'll keep digging to see if there's an even simpler solution. I wish I didn't have to add the preventDefault script part.hundreds-camera-24900
04/03/2022, 4:22 PM