https://htmx.org logo
Join Discord
Powered by
# htmx-general
  • w

    white-motorcycle-95262

    11/15/2022, 8:31 PM
    Not familiar with
    hx-preserve
    , I'll look into it
  • w

    white-motorcycle-95262

    11/15/2022, 8:31 PM
    yeah, I guess now that I think of it the ideas I was thinking of (returning partial results of search queries) were targeting a div outside of the input
  • w

    white-motorcycle-95262

    11/15/2022, 8:32 PM
    "Note that some elements cannot unfortunately be preserved properly, such as (focus and caret position are lost), iframes or certain types of videos. "
  • w

    white-motorcycle-95262

    11/15/2022, 8:32 PM
    I mean, I know I'm asking for the world so maybe I just need to refactor a little
  • m

    mysterious-toddler-20573

    11/15/2022, 8:32 PM
    merging it is!
  • m

    mysterious-toddler-20573

    11/15/2022, 8:32 PM
    man, I wish the DOM wasn't so touchy
  • m

    mysterious-toddler-20573

    11/15/2022, 8:33 PM
    https://github.com/bigskysoftware/idiomorph#htmx
  • m

    mysterious-toddler-20573

    11/15/2022, 8:33 PM
    let me throw an example together
  • m

    mysterious-toddler-20573

    11/15/2022, 8:33 PM
    make sure it works before you go down this road
  • w

    white-motorcycle-95262

    11/15/2022, 8:35 PM
    Yeah, I guess since the coupon is really nestled into the shopping cart, it would be difficult to return a response that wraps around it:
  • m

    mysterious-toddler-20573

    11/15/2022, 8:36 PM
    OK, another idea
  • m

    mysterious-toddler-20573

    11/15/2022, 8:37 PM
    (I am working on that demo
  • m

    mysterious-toddler-20573

    11/15/2022, 8:37 PM
    what if you target an error message after the input
  • m

    mysterious-toddler-20573

    11/15/2022, 8:37 PM
    and then, if the coupon is valid, trigger an event that refreshes the whole cart?
  • w

    white-motorcycle-95262

    11/15/2022, 8:38 PM
    Hey, not bad
  • w

    white-motorcycle-95262

    11/15/2022, 8:38 PM
    I like that. It would also save a lot of backend resources spent re-rendering the prices and everything
  • m

    mysterious-toddler-20573

    11/15/2022, 8:39 PM
    😅
  • m

    mysterious-toddler-20573

    11/15/2022, 8:39 PM
    dodged morphing again folks
  • w

    white-motorcycle-95262

    11/15/2022, 8:59 PM
    @mysterious-toddler-20573 instead of targeting/returning an error message after the input, if I just return a 204 (and still target the entire cart) would HTMX try to replace the cart with nothing, or would it not do a swap?
  • m

    mysterious-toddler-20573

    11/15/2022, 8:59 PM
    204 will do nothing by default
  • m

    mysterious-toddler-20573

    11/15/2022, 9:00 PM
    https://github.com/bigskysoftware/htmx/blob/822132d6a24d320aebc1ebcf85f721c3fc188218/src/htmx.js#L3048
  • w

    white-motorcycle-95262

    11/15/2022, 9:02 PM
    That seems nice, then. Return 204 if the promo code is wrong, otherwise send the new cart render
  • g

    gorgeous-airport-54386

    11/15/2022, 9:03 PM
    at last
  • g

    gorgeous-airport-54386

    11/15/2022, 9:03 PM
    the behavior I staked my reputation on is useful to someone
  • t

    thankful-apartment-66679

    11/15/2022, 9:03 PM
    successful operation but no content returned
  • w

    white-motorcycle-95262

    11/15/2022, 9:05 PM
    Now only 418 remains
  • w

    white-motorcycle-95262

    11/15/2022, 9:06 PM
    418 (specifically "teapot") is a Hitchhiker's Guide reference, is it not?
  • m

    mysterious-toddler-20573

    11/15/2022, 9:28 PM
    https://gist.github.com/1cg/4adaed5dad24dbad2c179d91423429e1
  • m

    mysterious-toddler-20573

    11/15/2022, 9:29 PM
    (I am incredibly unmotivated today)
  • w

    white-motorcycle-95262

    11/15/2022, 9:42 PM
    shouldn't it render...not a teapot? 🤔
1...908909910...1146Latest