mysterious-toddler-20573
02/26/2022, 4:26 AM<div hx-post="/search" hx-trigger="submit from:#theform">...</div>bulky-painting-16931
02/26/2022, 8:40 AMbulky-painting-16931
02/26/2022, 8:40 AMbulky-painting-16931
02/26/2022, 8:41 AMwhite-lion-11770
02/26/2022, 1:45 PM.active on the current nav-item and it is styled.
I've asked this question before and got recommended to try using tabs instead but that requires some hacks to make it look good, and it's more of a workaround than a solution for something that is likely a very common use-case. I'm sure there's some clever way to accomplish this with htmx.
I've tried naming all my nav-items and using hx-swap-oob to add .active to it when clicked but I don't know how to remove it when a different one is clicked. One thing I haven't tried yet, but that might work, is to hx-swap-oob in the entire navbar (or at least the part containing all the nav items) but that would result in a nightmare maintaining the block over several different files and keeping it uniform.
With Unpoly, the class .up-current can be added automatically and one can simply style that one: https://unpoly.com/up-nav. But I want to build with htmx and there has to be a way. Thankful for any suggestions.fast-nail-28668
02/26/2022, 1:47 PMhx-trigger="submit from:#theform" puts the event on the form, where hx-trigger="from:#theform" puts it on the div, which probably does nothing I'm guessing. I think which event (submit in this case) is the default assumption should be based on the from target, not the element the trigger is on. And in the case of a from being present in the trigger, the element identified by the from should get the event placed on it. What element gets what event handler is an implementation detail that might be over my head.bulky-painting-16931
02/26/2022, 2:41 PMbulky-painting-16931
02/26/2022, 2:44 PMbulky-painting-16931
02/26/2022, 2:45 PMbulky-painting-16931
02/26/2022, 2:51 PMbulky-painting-16931
02/26/2022, 2:52 PMwhite-lion-11770
02/26/2022, 3:01 PMhx-oob-swap swaps in a div from the target file, meaning that each file has to contain the nav block and if there's a change it would have to be implemented across all those files. Well there's probably only 3-4 of them, but still..white-lion-11770
02/26/2022, 3:28 PM.up-current is automagically added to the clicked nav-item and when a different nav-item is clicked, the class gets removed from the old nav-item and moved to the new one.mysterious-toddler-20573
02/26/2022, 3:38 PMfrom: unless it really adds clarity, and just put the hx- attributes on the element that will trigger the request. This is better for locality of behavior: https://htmx.org/essays/locality-of-behaviour/mysterious-toddler-20573
02/26/2022, 3:40 PMmysterious-toddler-20573
02/26/2022, 3:40 PMtake command that allows you to implement this pattern pretty easily: https://hyperscript.org/commands/take/white-lion-11770
02/26/2022, 3:43 PMmysterious-toddler-20573
02/26/2022, 3:54 PMwhite-lion-11770
02/26/2022, 4:02 PMwhite-lion-11770
02/26/2022, 4:06 PMmysterious-toddler-20573
02/26/2022, 4:12 PMmysterious-toddler-20573
02/26/2022, 4:12 PMmysterious-toddler-20573
02/26/2022, 4:18 PMmysterious-toddler-20573
02/26/2022, 4:18 PMnarrow-lifeguard-9228
02/26/2022, 4:18 PMplay command in Hyperscript? I saw play command using Web Audio API in the todo for 0.9.x release, but i'm not seeing anything else about it.mysterious-toddler-20573
02/26/2022, 4:19 PMmysterious-toddler-20573
02/26/2022, 4:20 PMnarrow-lifeguard-9228
02/26/2022, 4:20 PMnarrow-lifeguard-9228
02/26/2022, 4:21 PMmysterious-toddler-20573
02/26/2022, 4:21 PM