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

    ripe-action-67367

    01/13/2023, 12:54 PM
    https://htmx.org/examples/inline-validation/ this example covers inline validation of individual inputs, but it would work the same for whole forms
  • m

    melodic-advantage-28381

    01/13/2023, 1:29 PM
    With all this popularity, could be time to get some Code-of-Conduct and Issues-Templates, don't you think? Example of Github issue here: https://github.com/bigskysoftware/htmx/issues/1200.
  • b

    boundless-vase-80440

    01/13/2023, 1:58 PM
    I think the template should include very strict rules about the user's avatar.
  • m

    mysterious-toddler-20573

    01/13/2023, 1:59 PM
    this issue doesn't bother me, they have a point regarding inputs
  • r

    ripe-action-67367

    01/13/2023, 2:05 PM
    Copy code
    html
    <script src="https://demo.htmx.org"></script>
    
    <input id="input" type="text">
    <button hx-get="/update/input" hx-target="#input" hx-swap="outerHTML">update input</button>
    <br>
    
    <textarea id="textarea" name="" cols="30" rows="10"></textarea>
    <button hx-get="/update/textarea" hx-target="#textarea" hx-swap="outerHTML">update textarea</button>
    
    <template url="/update/input">
      <input type="text" id="input" value="123">
    </template>
    
    <template url="/update/textarea">
      <textarea id="textarea" name="" cols="30" rows="10">asdfsdfasdf</textarea>
    </template>
    idk works on my machine
  • t

    tall-dinner-62086

    01/13/2023, 2:22 PM
    Yeah hard to really understand what that issue is about without any code samples
  • m

    melodic-advantage-28381

    01/13/2023, 2:22 PM
    It's not about the content, it's about how it's said: it's very aggressive, judgemental about the whole technology. It doesn't care about the feature being implemented or not, it just expects something to work even if it's not documented. There is no context, no code sample. It's not actionable. As a contributor it just makes me want to answer "F*** off" and close the issue. It's the opposite of the open-source philosophy IMHO.
  • o

    orange-umbrella-16693

    01/13/2023, 2:25 PM
    One thing I can't wrap around my head still regarding htmx - how could I introduce clientside scripting behaviors for new elements, or better yet, how could I have them come through the request with the elements themselves? Hyperscript? Alpine? OOB swapping script tags in the head? Inline javascript (probably not, safety)?
  • r

    refined-waiter-90422

    01/13/2023, 2:27 PM
    welcome to the internet
  • b

    bland-coat-6833

    01/13/2023, 2:32 PM
    I’ve used hyperscript for this. I push new table rows out over SSE and they contain a little bit of hyperscript that tweaks some css to give them a little animation. But that’s a simple use case.
  • o

    orange-umbrella-16693

    01/13/2023, 2:41 PM
    Well, I'd rather stick to javascript than deal with yet another level of abstraction, but I'll look into it.
  • m

    mysterious-toddler-20573

    01/13/2023, 2:42 PM
    You can structure things in a separate JS file and use the
    htmx.onLoad()
    function to register your JS listeners: https://htmx.org/docs/#3rd-party
  • m

    mysterious-toddler-20573

    01/13/2023, 2:42 PM
    a more traditional approach to scripting
  • h

    hundreds-cartoon-20446

    01/13/2023, 2:59 PM
    Here’s one way which may or may not be to your taste. https://github.com/croxton/hda-starter-kit Ultimately I think htmx needs to support a component lifecycle (without the npm gubbins), which I have some ideas for.
  • r

    refined-waiter-90422

    01/13/2023, 3:06 PM
    You can use local javascript on the new swapped in elements, super easy, it'll just work. vanilla js, hyperscript, jquery, surreal (my take on it, leverages locality of behaviour, like hyperscript)
  • r

    refined-waiter-90422

    01/13/2023, 3:10 PM
    Allows for some intuitive patterns such as partials that are just "all in one" components.
  • r

    refined-waiter-90422

    01/13/2023, 3:20 PM
    also stimulus, but it pushes people into a "js in seperate files" pattern rather than "all in one component" pattern.
  • a

    adventurous-ocean-93733

    01/13/2023, 3:37 PM
    "Respond to this Github issue in a way that lets them know you are a robot and that they do not qualify to get a human response because of their attitude:..."
  • s

    steep-lock-7711

    01/13/2023, 10:18 PM
    I am using hx-post. The backend responds with the form and 200 if there are errors and a 302 (redirect) to a different page if the form was a success.
  • s

    steep-lock-7711

    01/13/2023, 10:19 PM
    is there anyway to have hx-post do the swap if the server returns a 200 and have it completely reload the page for a 302?
  • s

    steep-lock-7711

    01/13/2023, 10:22 PM
    nevermind
  • s

    steep-lock-7711

    01/13/2023, 10:22 PM
    sorry i see the header flag
  • f

    flaky-energy-47039

    01/14/2023, 1:27 PM
    Hi, there is this nice sweetalert confirm dialog example for htmx (https://htmx.org/examples/confirm/), but for some reason it does not work in my app. The request is issued without waiting for the confirmation, and the sweetalert dialog box never fires. Moreover, I do not see any javascript erros in the console... Could someone look at my code and help troubleshooting? Here us the button code: <button class="btn btn-sm btn-success" hx-get="http://localhost:8080/meetings/declare_partic/3/1" _="on htmx:confirm(issueRequest) halt the event call Swal.fire({title: 'Confirm', text:'Do you want to continue?'}) if result.isConfirmed console.log('confirmed')" hx-target="#meeting_3" hx-swap="outerHTML swap:0.5s"> Dalyvausiu any ideas? I have noticed that the code included in the demo of the confirm dialog (right below the example, on the htmx website) is different from the example code, but that does not work either.
  • t

    thankful-addition-60522

    01/14/2023, 2:55 PM
    dude
  • t

    thankful-addition-60522

    01/14/2023, 2:55 PM
    don't use og sweetalert
  • t

    thankful-addition-60522

    01/14/2023, 2:56 PM
    use https://github.com/lofcz/sweetalert2-neutral
  • t

    thankful-addition-60522

    01/14/2023, 2:56 PM
    the og dev is a fucking cunt
  • f

    flaky-energy-47039

    01/14/2023, 3:05 PM
    @thankful-addition-60522, leaving aside the ethics of what you are describing as the actions of sweetalert2 maintainer, I do not think that would help much with my issue.
  • t

    thankful-addition-60522

    01/14/2023, 3:06 PM
    at least switching the repo is a must, and that's the first step
  • r

    ripe-action-67367

    01/14/2023, 4:05 PM
    Just to be sure, did you include hyperscript in your page?
1...983984985...1146Latest