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

    some-hairdresser-28401

    08/25/2022, 11:56 AM
    Or I could use HTMX events via response headers.
  • e

    echoing-book-71490

    08/25/2022, 12:15 PM
    Not gonna fight you on that, I've seen these solutions work as well and great that it works for you! Just saying that I personally wouldn't consider them when I'm asked to "build a mobile app" in most circumstances for the reasons mentioned above and because going native is not that much more difficult or expensive (YMMV on that)
  • m

    melodic-book-40892

    08/25/2022, 2:14 PM
    Am trying to submit a form via GET when any of the inputs change. I've got htmx to make the request but I can't get any of the values of the form inputs to be included in the GET request, am I missing something?
    Copy code
    <form autocomplete="off" hx-get="{% url 'listings:search' %}" hx-params="*" hx-target="#results-list" hx-select="#results-list"
          hx-indicator="#results-list" hx-swap="outerHTML settle:1s" hx-trigger="change">
  • b

    breezy-kilobyte-4067

    08/25/2022, 2:43 PM
    I'm trying out htmx atm and am comparing it with rails/hotwire ,and I'm new to both. I'm trying to implement click to edit as described https://htmx.org/examples/click-to-edit/. I'm using htmx's
    htmx:configRequest
    as described here https://htmx.org/docs/#config_request_with_events to set a "Content-Type" and "X-CSRF-Token" header before the AJAX request is sent to the server. This event is firing and setting the headers correctly when page loaded initially, but it isn't firing subsequently when clicking on the "submit" button (for example) that is in the html that is returned from the server. Is there a recommended way to resolve this? Apologies if this is a basic question.
  • m

    mysterious-toddler-20573

    08/25/2022, 6:21 PM
    Where are you adding the code that sets the token?
  • m

    mysterious-toddler-20573

    08/25/2022, 6:21 PM
    If that’s set it p globally you should be good
  • m

    mysterious-toddler-20573

    08/25/2022, 6:21 PM
    Set up
  • b

    breezy-kilobyte-4067

    08/25/2022, 7:02 PM
    It's not global, but rather just on the page with the initial and upated content. I'll make it global per your recommendation.
  • b

    breezy-kilobyte-4067

    08/25/2022, 7:11 PM
    Setting global didn't work. I'm going to try and simplify things a bit. I'm adding this to an existing application along side rails/hotwire (as I'm experimenting) and perhaps there's some interaction going on that I'm not aware of.
  • m

    mysterious-toddler-20573

    08/25/2022, 7:11 PM
    Can you show me how you are adding the code? I know rails pretty well. Also, is turbolinks in play?
  • b

    breezy-kilobyte-4067

    08/25/2022, 7:33 PM
    Thanks. Yes, let me figure out a way to share it. I don't think it's at play. I attempted to disable it.
  • b

    breezy-kilobyte-4067

    08/25/2022, 8:12 PM
    Here's a gist that contains (as far as I can tell) all the relevant code. https://gist.github.com/tdouce/7cd6fe20012828dedeff7eaec22614e6 . I add some comments describing why I'm doing somethings and noted
    PROBLEM
    where I think there's an issue.
  • m

    mysterious-toddler-20573

    08/25/2022, 8:14 PM
    OK, that looks right
  • m

    mysterious-toddler-20573

    08/25/2022, 8:14 PM
    I might put the javascript in application.js if you have one
  • b

    breezy-kilobyte-4067

    08/25/2022, 8:14 PM
    I tried that previously.
  • m

    mysterious-toddler-20573

    08/25/2022, 8:14 PM
    If htmx is triggering requests, it seems like that has to be called
  • b

    breezy-kilobyte-4067

    08/25/2022, 8:15 PM
    I agree. I'm obviously missing something. I'll look in more detail. Thank you for helping.
  • b

    breezy-kilobyte-4067

    08/25/2022, 8:32 PM
    Ok. I think I figured it out. The form is beiing submitted as a standard html form submission and not via htmx. I'm not entirely sure why, but I believe it's because the
    action
    html attribute is set and/or maybe some other attribute or hidden input generated by the Rails form helper. Either way it is overriding/superceding the htmx request. I believe this because I manually created the form html without using the Rails form helpers and it worked. I would like to use the standard Rails form helpers, but I might have to build a custom one. Are there any suggestions on the best approach?
  • b

    breezy-kilobyte-4067

    08/25/2022, 8:33 PM
    I thought I was overriding the
    action
    html attribute in the Rails form helper, but I wasn't.
  • m

    mysterious-toddler-20573

    08/25/2022, 8:40 PM
    there is a way to pass custom html attributes into the standard form helpers
  • m

    mysterious-toddler-20573

    08/25/2022, 8:40 PM
    I haven't looked at it in a while, but I know that's the case
  • b

    breezy-kilobyte-4067

    08/25/2022, 8:45 PM
    Yes, you are correct. I need to look at the form helper documentation and figure out how to override the guilty attributes.
  • b

    breezy-kilobyte-4067

    08/25/2022, 8:46 PM
    Once I figure it out, I'll report back. I'm sure this can't be a new issue with htmx + rails integration.
  • g

    green-flower-49070

    08/25/2022, 8:56 PM
    required
  • s

    square-manchester-95442

    08/25/2022, 9:34 PM
    Anyone ever tried using web socket extension in spring boot?
  • s

    square-manchester-95442

    08/25/2022, 9:35 PM
    We don’t need sockJS in order to make it work right?
  • m

    mysterious-toddler-20573

    08/25/2022, 9:49 PM
    shouldn't need any additional front end libraries
  • s

    square-manchester-95442

    08/25/2022, 9:55 PM
    I’m going to try it soon to see if it works
  • m

    mysterious-toddler-20573

    08/26/2022, 11:14 PM
    from my students
  • m

    mysterious-toddler-20573

    08/26/2022, 11:46 PM
    anti-graphqlites rise up
1...798799800...1146Latest